05.03 Abstraction Generalisation Inheritance Polymorphism - Quiz¶
Check your understanding
-
What is the primary purpose of abstraction in object-oriented programming?
- To make code run faster
- To hide complexity and expose only essential features { data-correct }
- To create more classes
- To use more memory
-
Which concept involves identifying common characteristics across different objects?
- Abstraction
- Generalisation { data-correct }
- Inheritance
- Polymorphism
-
Look at this code. What concept does it demonstrate?
- Abstraction
- Generalisation
- Inheritance { data-correct }
- Polymorphism
-
What is polymorphism in object-oriented programming?
- Creating multiple classes
- Same interface, different behavior { data-correct }
- Using multiple inheritance
- Having many attributes
-
Which Python concept allows objects to be used polymorphically without formal inheritance?
- Type checking
- Duck typing { data-correct }
- Method overriding
- Class inheritance
-
In this code, what concept allows the
play_instrumentsfunction to work with different instrument types?- Abstraction
- Generalisation
- Inheritance
- Polymorphism { data-correct }
-
What does the
super()function do in inheritance?- Creates a new class
- Calls methods from the parent class { data-correct }
- Deletes the parent class
- Makes the class abstract
-
Which statement about inheritance is correct?
- Child classes cannot override parent methods
- Child classes inherit all attributes and methods from parents { data-correct }
- Parent classes inherit from child classes
- Inheritance makes code slower
-
What makes this an example of good abstraction?
- It uses a short method name
- It hides the complex file operations behind a simple interface { data-correct }
- It only works with text files
- It’s written in Python
-
Which scenario best demonstrates the need for generalisation?
- Creating a single class for one specific object
- Finding common features among cars, trucks, and motorcycles to create a Vehicle class { data-correct }
- Writing separate code for each different situation
- Using only concrete classes