This test assesses the understanding of subclassing, inheritance, and extensions in Swift, focusing on the fundamental concepts of object-oriented programming.
1.
What does inheritance allow in object-oriented programming?
2.
What is another name for a class from which a subclass is derived? (select all that apply)
3.
In Swift, how many direct parent classes can a subclass have?
4.
What is the name of the class at the top of a class hierarchy?
5.
What would be the best way to create a savings account class based on an existing BankAccount class?
6.
In Swift, which of the following is used to indicate a subclass?
7.
What does the override keyword do in Swift?
8.
When overriding a method, what must be true about the parameters and return type?
9.
Why might you override a method rather than creating a new one in a subclass?
10.
How can a subclass method call the method it overrides in the superclass?
11.
When must the init method of the superclass be called during subclass initialization?
12.
What is the primary difference between subclassing and extensions in Swift?
13.
What can extensions in Swift be used to add to existing classes?
14.
How are extensions declared in Swift?
15.
What advantage do extensions have over subclassing?
16.
Which of the following is true about extensions in Swift?
17.
Which example shows a valid use of extensions?
18.
Which of the following statements about Swift extensions is true?
19.
How does single inheritance in Swift influence class design?
Congratulations on completing the Swift Subclassing and Extensions Quiz.
Click the Submit button to review your results.
Enter your email address below if you would like to receive a copy of your test results.