In this example, a single interface, Game" is created, for two classes, SingleplayerGame and MultiplayerGame. This is on the surface a logical structure. However, in this case, the methods getServerList and pauseGame, published in the Game interface, are not used by both clients (As a MultiplayerGame cannot be paused, and a SingleplayerGame does not have servers).Because of this mismatch, the SingleplayerGame is forced to throw an UnsupportedOperationException when getServerList is called on it, and MultiplayerGame is forced to throw an UnsupportedOperationException when pauseGame is called on it. Which SOLID principle is violated here? . (SRP, OCP, LSP, ISP, or DIP) The Single Responsibility Principle (SRP) The Open-Closed Principle (OCP) The Liskov Substitution Principle (LSP) The Interface Segregation Principle (ISP) The Dependency Inversion Principle (DIP)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
In this example, a single interface, Game" is created, for two classes, SingleplayerGame and MultiplayerGame. This is on the surface a logical structure. However, in this case, the methods getServerList and pauseGame, published in the Game interface, are not used by both clients (As a MultiplayerGame cannot be paused, and a SingleplayerGame does not have servers).Because of this mismatch, the SingleplayerGame is forced to throw an UnsupportedOperationException when getServerList is called on it, and MultiplayerGame is forced to throw an UnsupportedOperationException when pauseGame is called on it.
Which SOLID principle is violated here? . (SRP, OCP, LSP, ISP, or DIP)
The Single Responsibility Principle (SRP)
The Open-Closed Principle (OCP)
The Liskov Substitution Principle (LSP)
The Interface Segregation Principle (ISP)
The Dependency Inversion Principle (DIP)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps