← Quiz: SOLID in Java: all 10 questions
Quiz: SOLID in Java · Question 6 of 10
An interface has print(), scan() and fax(). A basic printer must implement all three. What is the best fix?
An interface has print(), scan() and fax(). A basic printer must implement all three. What is the best fix?
- A.Make
scan()andfax()return null - B.Use an abstract class instead of an interface
- C.Split it into
Printer,ScannerandFaxinterfaces - D.Put all three methods in the basic printer and throw exceptions
Answer & explanation
Correct answer: Split it into Printer, Scanner and Fax interfaces
Interface segregation: classes implement only the small interfaces they can really support.
Can you get the rest right without peeking?
Take the timed Quiz: SOLID in Java quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →