
Inheritance
Authored by Dhilma Dhilma
Computers
12th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What type of inheritance is illustrated in the following Python code?
Multi-level inheritance
Multiple inheritance
Hierarchical inheritance
Single-level inheritance
Answer explanation
In multiple inheritance, two or more subclasses are derived from the superclass as shown in the above piece of code.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Python code?
A A
A B
B B
An exception is thrown
Answer explanation
obj1.two() invokes the method two() in class A which returns ‘A’ and obj2.two() invokes the method two() in class B which returns ‘B’.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is not a type of inheritance?
Double-level
Multi-level
Single-level
Multiple
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Python code?
Error, the syntax of the invoking method is wrong
The program runs fine but nothing is printed
1 0
1 2
Answer explanation
The invoking method has been properly implemented and hence x=1 and y=2.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Python code?
Error because class B inherits A but variable x isn’t inherited
0 0
0 1
Error, the syntax of the invoking method is wrong
Answer explanation
The invoking method has been properly invoked, variable x from the main class has been properly inherited and it can also be accessed.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Suppose B is a subclass of A, to invoke the init method in A from B, what is the line of code you should write?
A.__init__(self)
B.__init__(self)
A.__init__(B)
B.__init__(A)
Answer explanation
To invoke the init method in A from B, either of the following should be written: A.__init__(self) or super( ).__init__( ).
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Python code?
Invalid syntax for inheritance
Error because when object is created, argument must be passed
Nothing is printed
A disp( )
Answer explanation
Class B inherits class A hence the function disp () becomes part of class B’s definition. Hence disp() method is properly executed and the line is printed.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Aspek Legal TIK
Quiz
•
12th Grade
10 questions
python-BTxâu
Quiz
•
9th - 12th Grade
10 questions
Logic Gates
Quiz
•
9th - 12th Grade
10 questions
Working around Adobe Photoshop
Quiz
•
12th Grade
10 questions
Keyboarding Terms
Quiz
•
9th - 12th Grade
10 questions
Kolaborasi dalam Masyarakat digital
Quiz
•
12th Grade
10 questions
Data Dictionary Quiz
Quiz
•
12th Grade
10 questions
Word basics
Quiz
•
8th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade