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?
- A. Liskov Substitution Principle
- B. Interface Segregation Principle
- C. Single Responsibility Principle
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Which situation in Git definitely produces a merge conflict?
- Which type of coupling between two modules is the loosest (most desirable)?
- A function is: c if (a > 0) x = 1; if (b > 0) y = 1; What is the minimum number of test cases for 100% branch (decision) coverage?
- A system accepts an age from 18 to 60 inclusive. Using equivalence partitioning, what is the minimum number of test cases to cover all…
- A Scrum team completed 24, 30 and 27 story points in its last three sprints. The remaining backlog is 162 points. Using average velocity…
- A developer checks out a specific commit by its hash and makes two new commits, then switches to main without creating a branch. What is…