Whats wrong in this Java code? ---- class TriPism { public static void main(String[] args) { myFrog = new Frog(); myBird = new Bird(); myHorse = new Horse(); myFrog.animalSound(); myFrog.jump(); myBird.animalSound(); myBird.fly(); myHorse.animalSound(); myHorse.kick(); } } abstract class Animal { public abstract void animalSound(); public void jump() { System.out.println("kokak!"); } public void fly() { System.out.println("Twit!"); } public void kick() { System.out.println("Boogsh!"); } } class Bird extends Animal { public void animalSound() { System.out.println("The bird says: Twit!"); } } class Horse extends Animal { public void animalSound() { System.out.println("The Horse says: Boogsh!"); } } class Frog extends Animal { public void animalSound() { System.out.println("The frog says: kokak!"); } }
Whats wrong in this Java code?
----
class TriPism {
public static void main(String[] args) {
myFrog = new Frog();
myBird = new Bird();
myHorse = new Horse();
myFrog.animalSound();
myFrog.jump();
myBird.animalSound();
myBird.fly();
myHorse.animalSound();
myHorse.kick();
}
}
abstract class Animal {
public abstract void animalSound();
public void jump() {
System.out.println("kokak!");
}
public void fly() {
System.out.println("Twit!");
}
public void kick() {
System.out.println("Boogsh!");
}
}
class Bird extends Animal {
public void animalSound() {
System.out.println("The bird says: Twit!");
}
}
class Horse extends Animal {
public void animalSound() {
System.out.println("The Horse says: Boogsh!");
}
}
class Frog extends Animal {
public void animalSound() {
System.out.println("The frog says: kokak!");
}
}
Step by step
Solved in 4 steps with 3 images