Pythondex

Quiz

Classes Inheritance Quiz in Python

What is a class in Python?

A blueprint for creating objects
A type of variable
A function that prints values
A Python module

What is an object in Python?

A variable storing numbers only
An instance of a class
A type of function
A Python keyword

What will the code above print?

Dog
my_dog
Buddy
Error

Which method is called from the parent class?

start()
honk()
__init__()
None

Which method will run when my_car.start() is called?

Vehicle.start()
Car.start()
Both methods
Error

What will be the output of the code above?

Vehicle starting
Car is ready
Vehicle starting\nCar is ready
Error

Why do we use inheritance in Python?

To avoid writing the same code again
To store variables in a file
To make loops faster
To define functions inside functions