ProgrammingHardGATE CS · Product-company placement

An interface Machine declares print(), scan() and fax(). A SimplePrinter class implements it and has to make scan() and fax() throw UnsupportedOperationException. Which principle is violated?

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

Correct answer: D. Interface Segregation Principle

Clients should not be forced to depend on methods they do not use. Splitting Machine into Printer, Scanner and Fax interfaces lets SimplePrinter implement only what it supports.

More OOP with C++ and Java questions

Exams that ask this topic