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

Quiz: SOLID Principles: questions with answers

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

Take the timed quiz + get a certificate →
  1. Q1. A class calculates salary, formats the payslip PDF and saves it to the database. Which principle does it break?
  2. Q2. What does "open for extension, closed for modification" mean?
  3. Q3. What does this print? (code)
  4. Q4. Square extends Rectangle and changes setwidth so that it also sets the height. Code written for Rectangle now gives wrong areas. Which prin…
  5. Q5. A BasicPrinter class implements a Machine interface and raises an error in scan() and fax(). What is the best fix?
  6. Q6. According to Dependency Inversion, what should a high-level FeeReminder class depend on?
  7. Q7. What does this print? (code)
  8. Q8. What is the main practical benefit of dependency injection?
  9. Q9. Which statement about DRY is correct?
  10. Q10. A student writes eight interfaces and a factory for a 40-line script used once. Which idea warns against this?