← All topics
Quiz: SOLID in Java: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. In the original ResultService.publish(), how many different reasons to change did the class have?
- Q2. A PaymentProcessor has if (type.equals("UPI")) … else if (type.equals("CARD")) …. Adding NetBanking needs another else if. Which principle…
- Q3. What does this print? (code)
- Q4. A subclass overrides a method and throws UnsupportedOperationException. Which principle is most likely broken?
- Q5. Why is ResultService(ResultStore store, Notifier notifier) easier to test than a class that does new MySqlStore() inside?
- Q6. An interface has print(), scan() and fax(). A basic printer must implement all three. What is the best fix?
- Q7. What does this print? (code)
- Q8. Dependency Inversion says high-level modules should depend on:
- Q9. Which statement about Dependency Injection is correct?
- Q10. When is applying SOLID strictly NOT worth it?