🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Multiple Inheritance and the Diamond Problem: all 10 questions

Quiz: Multiple Inheritance and the Diamond Problem · Question 3 of 10

Both bases of a class define status(). What happens when you call obj.status() without overriding it?

Both bases of a class define status(). What happens when you call obj.status() without overriding it?

  1. A.The first base's version is used
  2. B.The last base's version is used
  3. C.Compile error: the call is ambiguous
  4. D.Both versions run
Answer & explanation

Correct answer: Compile error: the call is ambiguous

The compiler refuses to guess; use obj.Base::status() or override status() in the derived class.

Can you get the rest right without peeking?

Take the timed Quiz: Multiple Inheritance and the Diamond Problem quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →