Computer Science, asked by rewaasrour2000, 5 months ago

Explain the outputs (or error) for the following test program.

public class TestAnimal {

public static void main (String [ ] args) {

// Using the subclasses

Cat cat1 = new Cat ();

cat1.greeting () ;

Dog dogl= new Dog();

dogl.greeting () ;

Bigoog bigDogl new Bigbog () ;

bigoog1.greeting () ;

// Using Polymorphism

Animal animal1 = new Cat ();

animal1.greeting () ;

Animal animal2 = new Dog();

animal2.greeting () ;

Animal animal3 new Bigbog () ;

animal3.greeting () ;

Animal animal4 =new Animal ();

//Downcast

Dog dog2= (Dog) animal2;

Bigbog bigDog2= (Bigoog) animal3;

Dog dog3 = (Dog) animal3;

Cat cat2 = (Cat) animal2;

dog2.greeting (dog3) ;

dog3.greeting (dog2) ;

dog2.greeting (bigDog2);

bigDog2.greeting (dog2);

bigbog2.greet ing (bigDog1);
}
}

Answers

Answered by SWARAJBARNWAL
0

Answer:

please mark my answer as brainliest l will follow u

Similar questions