Inheritance

Inheritance

12th Grade

7 Qs

quiz-placeholder

Similar activities

Python

Python

8th Grade - Professional Development

10 Qs

Python Classes

Python Classes

9th - 12th Grade

11 Qs

Python L2- Quiz 6

Python L2- Quiz 6

5th - 12th Grade

8 Qs

Python Basic files

Python Basic files

10th - 12th Grade

10 Qs

Understanding Procedures in Python

Understanding Procedures in Python

9th Grade - University

10 Qs

PI Mod 1 test

PI Mod 1 test

9th - 12th Grade

10 Qs

Python Functions 2

Python Functions 2

11th - 12th Grade

12 Qs

Python Programming Concepts Challenge

Python Programming Concepts Challenge

10th Grade - University

10 Qs

Inheritance

Inheritance

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Dhilma Dhilma

Used 3+ times

FREE Resource

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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.