
Inheritance

Quiz
•
Computers
•
12th Grade
•
Hard
Dhilma Dhilma
Used 3+ times
FREE Resource
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.
Similar Resources on Wayground
10 questions
Interfaces en Python

Quiz
•
12th Grade
11 questions
Quiz on Python Functions

Quiz
•
12th Grade
8 questions
Python - 3.4.13 - Lists Quiz

Quiz
•
12th Grade
10 questions
Python Turtle - Homework

Quiz
•
12th Grade
10 questions
Object-Oriented Programming (OOP) in Python 3 Quiz

Quiz
•
12th Grade
12 questions
Data visualization

Quiz
•
10th Grade - University
11 questions
Dia 5

Quiz
•
12th Grade
10 questions
Django Start

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade