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