← Quiz: Composition vs Inheritance: all 10 questions
Quiz: Composition vs Inheritance · Question 3 of 10
In the composition version, why is there no double counting?
In the composition version, why is there no double counting?
- A.
inner.addAll()callsinner's ownadd, which our class did not override - B.Composition makes methods run only once
- C.Java removes duplicate calls automatically
- D.Because
addAllwas deleted
Answer & explanation
Correct answer: inner.addAll() calls inner's own add, which our class did not override
Our class wraps the set; the set's internal calls never come back to our methods.
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 →