← Quiz: Composition vs Inheritance: all 10 questions
Quiz: Composition vs Inheritance · Question 6 of 10
Which is a good use of inheritance?
Which is a good use of inheritance?
- A.
Car extends Engineto reuse the start() method - B.
InvalidMarksException extends RuntimeException - C.
Stack extends Vectorto reuse storage - D.
Student extends ArrayListto store subjects
Answer & explanation
Correct answer: InvalidMarksException extends RuntimeException
An exception genuinely is a RuntimeException; the others only want to reuse code.
Can you get the rest right without peeking?
Take the timed Quiz: Composition vs Inheritance quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →