class Animal { public void animalSound() { System.out.println("Animals make sounds lol"); } } class Pig extends Animal { public void animalSound() { System.out.println("The pig goes oink"); } } class...


class Animal {
    public void animalSound() {
        System.out.println("Animals make sounds lol");
    }
}


class Pig extends Animal {
    public void animalSound() {
        System.out.println("The pig goes oink");
    }
}


class Dog extends Animal {
    public void animalSound() {
        System.out.println("The dog goes woof");
    }
}


public class Main {
    public static void main(String[] args) {
        Animal myAnimal = new Animal();
        Animal myPig = new Pig();
        Animal myDog = new Dog();
        // animal class method called
        myAnimal.animalSound();
        // Pig class method called
        myPig.animalSound();
        // Dog class method called
        myDog.animalSound();
    }
}



I created a polymorphism program and I want to know is which is the parent class and what is the child...



Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here