Question 11
EasyWhat is hybrid inheritance?
- A.
A combination of two or more types of inheritance
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
What is hybrid inheritance?
A combination of two or more types of inheritance
Inheritance used only in Python
Inheritance between two programs
Inheritance with no base class
Sign up free to see the answer and a step-by-step explanation.
In C++, what does the word public mean in class Dog : public Animal?
Dog becomes a public variable
Dog cannot be inherited further
Animal can access Dog's private members
Public inheritance: Animal's public members stay public in Dog
Sign up free to see the answer and a step-by-step explanation.
Which Python syntax makes Dog inherit from Animal?
class Dog inherits Animal:
class Dog : Animal
class Dog extends Animal:
class Dog(Animal):
Sign up free to see the answer and a step-by-step explanation.
From which class does every Java class ultimately inherit?
Main
System
Object
Class
Sign up free to see the answer and a step-by-step explanation.
What does a derived class get from its base class?
Nothing at all
Only its private members
Only the base class's name
The base class's accessible fields and methods
Sign up free to see the answer and a step-by-step explanation.
What is the main benefit of inheritance?
Reusing existing code instead of writing it again
Making programs run faster
Avoiding classes altogether
Hiding data
Sign up free to see the answer and a step-by-step explanation.
Which of these is an 'is-a' relationship suitable for inheritance?
A car uses fuel
A car is parked in a garage
A car has an engine
A car is a vehicle
Sign up free to see the answer and a step-by-step explanation.
Which of these is a 'has-a' relationship, better modelled by composition?
A car has an engine
A car is a vehicle
A square is a shape
A dog is an animal
Sign up free to see the answer and a step-by-step explanation.
Does Python support multiple inheritance?
Only in Python 2
Only for built-in classes
Yes, a class can list several parent classes
No, never
Sign up free to see the answer and a step-by-step explanation.
In Python, which built-in is used to call a method of the parent class?
super()
parent()
this()
base()
Sign up free to see the answer and a step-by-step explanation.