Welcome to the quiz on Kotlin Inheritance and Subclassing! This quiz will test your understanding of how inheritance works in Kotlin, including concepts like subclassing, the open keyword, method overriding, and the use of constructors in parent and child classes. By taking this quiz, you will reinforce your knowledge of creating class hierarchies and extending classes to add new functionality.
1.
What keyword is used in Kotlin to allow a class to be subclassed?
2.
What is the purpose of subclassing?
3.
What is the difference between 'open' and 'override' in Kotlin?
4.
What is the base class from which all classes in Kotlin are ultimately derived?
5.
What must be included in the subclass if the parent class has a secondary constructor?
6.
Why might you want to override a method in a subclass?
7.
How do you call a superclass method from an overridden method in Kotlin?
8.
Which of the following correctly creates a secondary constructor in a subclass?
9.
What is required when creating a subclass that has a constructor with parameters?
10.
How do you override a method in Kotlin?
11.
What is a class hierarchy?
12.
What is inheritance in Kotlin?
13.
Which method in a subclass allows calling a method with the same name from the parent class?
14.
Which keyword is used to access the parent class's properties or methods in Kotlin?
15.
What is the term for a class from which a subclass is derived?
16.
What is the benefit of using a secondary constructor in a subclass?
17.
Which of the following correctly defines a subclass in Kotlin?
18.
Which of the following is true about the 'super' keyword in Kotlin?
19.
Why is the 'open' keyword required before a function to allow it to be overridden?
20.
What happens if you try to override a method that is not declared as 'open' in the parent class?
21.
What is single inheritance in Kotlin?