Interfaces
You love all animals, and have a dog and a cat as pets. class Main { public static void main(String[] args) { Animal dog = new Dog(); Animal cat = new Cat(); dog.swim(); cat.swim(); dog.play(); cat.play(); } } interface Swimmer { void swim(); } interface Player { void play(); } //implement the Swimmer and the Player interfaces class Animal implements Swimmer, Player{ } abstract class Animal{ } class Dog extends Animal { //Override the swim() and the play() methods @Override public void swim() { System.out.println("Dog is swimming"); } @Override public void play() { System.out.println("Dog is playing"); } } class Cat extends Animal { //Override the swim() and the play() methods @Override public void swim() { System.out.println("Cat is swimming"); } @Override public void play() { System.out.println("Cat is playing"); } } I can't find where is the problem here. it doesn't give any output.