Question: Consider the following code: class Animal { public void name ( ) { System.out.println ( animal ) ; } } class Cat extends

Consider the following code:
class Animal {
public void name(){
System.out.println("animal");
}
}
class Cat extends Animal {
public void name(){
System.out.println("cat");
}
}
class Program {
public static void main(String[] args){
Animal a = new Cat();
a.name();
}
}
What's the output of the program above?
Group of answer choices
None of these. It produces a compile error.
animal
cat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!