You are developing a system where you have a base class "User" and two derived classes "Admin" and "Guest". If you want to add a method that is only applicable for "Admin" and not for "Guest", where should you add that method to adhere to the Liskov Substitution Principle?
- In the "User" class
- In the "Admin" class
- In the "Guest" class
- In a separate utility function
To adhere to the Liskov Substitution Principle, you should add the method specific to "Admin" in the "Admin" class. This ensures that each derived class (Admin and Guest) can be used interchangeably with the base class (User) without violating the principle.
Loading...
Related Quiz
- The concept that allows JavaScript objects to inherit properties and behavior from an object of another class is known as _________.
- Which of the following best describes a JavaScript callback function?
- What is the drawback of using "inheritance" through the prototype chain?
- Which method is used to handle the successful resolution of a Promise?
- In JavaScript, instances are typically created using the _________ keyword.