+ 1

Abstract interfaces

I have no idea why this code is not printing anything. 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"); }

22nd Nov 2022, 7:25 PM
Natanael
2 Antworten
+ 8
Cat class not closed. Missing } at end.
22nd Nov 2022, 7:33 PM
Jayakrishna 🇮🇳
+ 2
Thank you so much
22nd Nov 2022, 9:01 PM
Natanael