Question: Not sure what I'm doing wrong. Need help. Please answer the question by writing what is the output from the tester code shown in the
Not sure what I'm doing wrong. Need help.
Please answer the question by writing what is the output from the tester code shown in the bottom box
| public class Animal (){ public String species; public Animal(){ species =unknown } public void a1 (){ System.out.println ("Animal 1"); } public void a2(){ System.out.println ("Animal 2"); } public String toString(){ return "Animal String "; } }
| public class Mammal extends Animal{ public int numFeet;
public Mammal (){ super(); numFeet=2; } public void a1 (){ System.out.println(Mammal a1); } public String toString(){ return " Mammal String "; } } |
| public class Human extends Mammal { public boolean brain;
public Human (){ super(); brain=true; }
public void a2(){ System.out.println("Human a2"); }
| public class Tester{
public static void main (String []args){ Animal [ ] zoo= { new Mammal(), new Animal ( ), new Human() }; for ( int i=0; i< zoo.length; i++){ zoo[ i ].a1(); System.out.println(zoo[ i ]); zoo[ i ].a2(); } }
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
