Question: The Athlete interface is an interface with some actions of an athlete: public interface Athlete { void compete(); void swim(); void highJump(); void longJump(); }

 The Athlete interface is an interface with some actions of an

The Athlete interface is an interface with some actions of an athlete: public interface Athlete { void compete(); void swim(); void highJump(); void longJump(); } We have added the method compete, but also there are some extra methods like swim, highJump, and longJump. Suppose that John Doe is a swimming athlete. By implementing the Athlete interface, we have to implement methods like highJump and longJump, which John Doe will never use. public class John Doe implements Athlete { @Override public void compete() { System.out.println("John Doe started competing"); } @Override public void swim() { System.out.println("John Doe started swimming"); } @Override public void highJump() { } @Override public void longlump() { } Which principle is violated in this approach? S - Single-responsibility principle. 0 - Open-closed principle. L - Liskov substitution principle. 1 - Interface segregation principle. D - Dependency Inversion Principle

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!