To check if an object is an instance of a specific class
B:
To create a new instance of a class
C:
To access class attributes directly
D:
To call a method of the superclass
Answer:A
The isinstance() function is used to determine if an object is an instance of a specified class or a tuple of classes.
Discuss About this Question.
How is multiple inheritance implemented?
A:
By using the extends keyword
B:
By using the inherit keyword
C:
By using the super() function
D:
By specifying multiple parent classes in the class definition
Answer:D
Multiple inheritance in Python is implemented by specifying multiple parent classes in the class definition, separated by commas.
Discuss About this Question.
What is method overriding?
A:
Creating a new method in the subclass
B:
Modifying the implementation of a method in the subclass
C:
Calling a method of the superclass
D:
Creating a new instance of the subclass
Answer:B
Method overriding in Python involves redefining a method in the subclass with the same name and parameters as in the superclass, thereby providing a new implementation.
Discuss About this Question.
What is the purpose of the super() function in Python when working with inheritance?
A:
To call the superclass constructor
B:
To create a new instance of the subclass
C:
To access class attributes directly
D:
To override a method in the superclass
Answer:A
The super() function is used to call the constructor of the superclass, allowing the subclass to initialize its own attributes while reusing the superclass's initialization code.
Discuss About this Question.
It is illegal to make objects of one class as members of another class.
Discuss About this Question.