← Quiz: SOLID Principles: all 10 questions
Quiz: SOLID Principles · Question 5 of 10
A BasicPrinter class implements a Machine interface and raises an error in scan() and fax(). What is the best fix?
A BasicPrinter class implements a Machine interface and raises an error in scan() and fax(). What is the best fix?
- A.Catch the errors in every caller
- B.Add more methods to
Machine - C.Make
BasicPrinterextendScanner - D.Split
Machineinto smaller interfaces such asPrinter,ScannerandFax
Answer & explanation
Correct answer: Split Machine into smaller interfaces such as Printer, Scanner and Fax
Interface Segregation: a class should only depend on methods it actually uses.
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 →