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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *