0

Animal lover, interfaces JAVA

class Main { public static void main(String[] args) { Animal dog = new Dog(); Animal cat = new Cat(); dog.swim(); dog.play(); cat.swim(); cat.play(); } } interface Swimmer { void swim(); } interface Player { void play(); } //implement the Swimmer and the Player interfaces abstract class Animal implements Swimmer, Player{ } class Dog extends Animal { //Override the swim() and the play() methods public void swim(){ System.out.println("Dog is swimming"); } public void play(){ System.out.println("Dog is playing"); } } } class Cat extends Animal { //Override the swim() and the play() methods public void swim(){ System.out.println("Cat is swimming"); } public void play(){ System.out.println("Cat is playing"); } } } this is my code that has no output, the problem is that it is identical to the solution offered ... what's the problem?

13th Sep 2022, 4:30 PM
Francesco Ilari
Francesco Ilari - avatar
1 Answer
+ 3
After dog and cat classes, you have extra } closing brace..
13th Sep 2022, 5:01 PM
Jayakrishna 🇼🇳