CS FundamentalsModerateAccenture · Cognizant GenC

A class has methods to calculate employee salary, save the employee to a database and print a payslip report. Which SOLID principle does it violate most directly?

  1. A. Liskov Substitution Principle
  2. B. Interface Segregation Principle
  3. C. Single Responsibility Principle
  4. D. Open/Closed Principle

Correct answer: C. Single Responsibility Principle

The class has three independent reasons to change (pay rules, persistence, reporting), which breaks the Single Responsibility Principle.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic