🎙 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 5 of 10

Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?

Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?

  1. A.class Copier : virtual public Printer, virtual public Scanner
  2. B.class Printer : virtual public Device and class Scanner : virtual public Device
  3. C.virtual class Device
  4. D.On Device's constructor
Answer & explanation

Correct answer: class Printer : virtual public Device and class Scanner : virtual public Device

The middle classes declare Device as a virtual base so that they share it.

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 →