Question: Consider the following two animal classes: public class Cat { public void c1() { System.out.println(cat 1); } public void c2() { System.out.println(cat 2); } public

Consider the following two animal classes:

public class Cat { public void c1() { System.out.println("cat 1"); } public void c2() { System.out.println("cat 2"); } public String toString() { return "meow"; } } public class Tiger extends Cat { public void c1() { System.out.println("tiger 1"); } }

Given the following declared variables, what is the output from the following statements?

Cat myCat = new Cat(); Tiger myTiger = new Tiger();

System.out.println(myCat); myCat.c1(); myCat.c2(); System.out.println(myTiger); myTiger.c1(); myTiger.c2();

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!