CS FundamentalsModerateCognizant · Capgemini pattern

Match each SOLID principle with the violation it forbids. P. Single Responsibility Q. Interface Segregation R. Open/Closed S. Dependency Inversion 1. A Printer interface forces a basic printer class to implement fax() and scan() 2. An Invoice class both calculates totals and writes itself to a PDF file 3. Adding a new shape means editing a switch statement inside an existing AreaCalculator 4. OrderService constructs a concrete SmtpMailer inside itself

  1. A. P-2, Q-1, R-3, S-4
  2. B. P-2, Q-1, R-4, S-3
  3. C. P-1, Q-2, R-3, S-4
  4. D. P-3, Q-1, R-2, S-4

Correct answer: A. P-2, Q-1, R-3, S-4

Two reasons to change → SRP (2); a fat interface → ISP (1); editing existing code to add a case → OCP (3); depending on a concrete class instead of an abstraction → DIP (4).

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic