🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: SOLID Principles: all 10 questions

Quiz: SOLID Principles · Question 1 of 10

A class calculates salary, formats the payslip PDF and saves it to the database. Which principle does it break?

A class calculates salary, formats the payslip PDF and saves it to the database. Which principle does it break?

  1. A.Liskov Substitution
  2. B.Single Responsibility
  3. C.Interface Segregation
  4. D.Dependency Inversion
Answer & explanation

Correct answer: Single Responsibility

Payroll rules, payslip layout and storage are three different reasons to change.

Can you get the rest right without peeking?

Take the timed Quiz: SOLID Principles quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →