Question: Consider the following code: class Animal { public void name ( ) , ( Systel.out.println ( aninal ) ) ; } class Cat

Consider the following code:
class Animal {
public void name(),(
Systel.out.println("aninal"));
}
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?
cat
None of these. It produces a compile error.
animal
Consider the following code: class Animal {

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 Programming Questions!