🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Multiple Inheritance and the Diamond Problem: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. In class Copier : public Printer, public Scanner, which constructor runs first when a Copier is created?
  2. Q2. What does this print? (code)
  3. Q3. Both bases of a class define status(). What happens when you call obj.status() without overriding it?
  4. Q4. What is the diamond problem?
  5. Q5. Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?
  6. Q6. With virtual inheritance, which class constructs the shared virtual base?
  7. Q7. What does this print? (code)
  8. Q8. How do you call Scanner's version of status() on a Copier object c?
  9. Q9. Why are interfaces (classes with only pure virtual functions) safe to combine with multiple inheritance?
  10. Q10. What is a cost of virtual inheritance?