0
0
Software Engineeringknowledge~20 mins

SOLID principles in Software Engineering - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SOLID Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the Single Responsibility Principle (SRP)

Which of the following best describes the Single Responsibility Principle?

AA class should depend on abstractions, not on concrete implementations.
BA class should have only one reason to change, meaning it should have only one job or responsibility.
CObjects of a superclass should be replaceable with objects of a subclass without affecting the correctness.
DA class should be open for modification but closed for extension.
Attempts:
2 left
💡 Hint

Think about how many reasons a class should have to change.

📋 Factual
intermediate
2:00remaining
Identifying the Open/Closed Principle (OCP)

Which statement correctly explains the Open/Closed Principle?

ADerived classes must be substitutable for their base classes.
BClasses should have only one responsibility.
CSoftware entities should be open for extension but closed for modification.
DDepend on concrete classes rather than abstractions.
Attempts:
2 left
💡 Hint

Consider how software should behave when new features are added.

🔍 Analysis
advanced
2:00remaining
Applying the Liskov Substitution Principle (LSP)

Given a base class Bird with a method fly(), and a subclass Penguin that cannot fly, which problem violates the Liskov Substitution Principle?

AReplacing <code>Bird</code> objects with <code>Penguin</code> objects causes errors when calling <code>fly()</code>.
BUsing interfaces to abstract bird behaviors.
CAdding new methods to <code>Bird</code> without changing <code>Penguin</code>.
DCreating a new subclass <code>Eagle</code> that can fly.
Attempts:
2 left
💡 Hint

Think about substituting a subclass where the base class is expected.

Comparison
advanced
2:00remaining
Distinguishing Dependency Inversion Principle (DIP)

Which option best illustrates the Dependency Inversion Principle?

AHigh-level modules depend on abstractions, not on low-level modules.
BClasses should have only one reason to change.
CDerived classes must be substitutable for their base classes.
DSoftware entities should be open for extension but closed for modification.
Attempts:
2 left
💡 Hint

Consider the direction of dependencies between high-level and low-level modules.

Reasoning
expert
3:00remaining
Evaluating Interface Segregation Principle (ISP) in Design

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?

AThe system becomes open for extension but closed for modification.
BClasses will have multiple reasons to change, violating the Single Responsibility Principle.
CSubclasses cannot replace base classes without errors.
DClasses are forced to implement methods they do not use, violating the Interface Segregation Principle.
Attempts:
2 left
💡 Hint

Think about interfaces and how they should be designed for clients.