Which of the following best describes the Single Responsibility Principle?
Think about how many reasons a class should have to change.
The Single Responsibility Principle states that a class should have only one reason to change, meaning it should focus on a single responsibility or job.
Which statement correctly explains the Open/Closed Principle?
Consider how software should behave when new features are added.
The Open/Closed Principle means software components should allow adding new functionality without changing existing code.
Given a base class Bird with a method fly(), and a subclass Penguin that cannot fly, which problem violates the Liskov Substitution Principle?
Think about substituting a subclass where the base class is expected.
Liskov Substitution Principle requires that subclasses can replace base classes without breaking the program. If Penguin cannot fly but inherits fly(), substituting it breaks expectations.
Which option best illustrates the Dependency Inversion Principle?
Consider the direction of dependencies between high-level and low-level modules.
The Dependency Inversion Principle states that high-level modules should not depend on low-level modules directly; both should depend on abstractions.
A software system has a large interface Printer with methods print(), scan(), and fax(). Some classes only need print(). What problem arises if these classes implement the full interface?
Think about interfaces and how they should be designed for clients.
The Interface Segregation Principle says clients should not be forced to depend on interfaces they do not use. Large interfaces cause unnecessary implementation burden.