Question: Inheritance and Polymorphism. Consider the following classes (System.out.println has been abbreviated as S.o.pln): public class Blue extends Green { public void one() { System.out.println(Blue 1);

Inheritance and Polymorphism. Consider the following classes (System.out.println has been abbreviated as S.o.pln): public class Blue extends Green { public void one() { System.out.println("Blue 1"); super.one(); In the table below, indicate in the right-hand column the output produced by the statement in the left-hand column. If the statement produces more than one line of output, indicate the line breaks with slashes as in "a / b / c" to indicate three lines of output with "a" followed by "b" followed by "c". If the statement causes an error, fill in the right-hand column with the phrase "error" to indicate this. } Statement} var1.one(); Output public class Red extends Yellow { public void one() { super.one(); System.out.println("Red 1"); } public void two() { System.out.println("Red 2"); super.two(); } } public class Yellow extends Blue { public void two() { System.out.println("Yellow 2"); } public void three() { two(); System.out.println("Yellow 3"); var1.two(); var1.three(); var2.one(); var2.two(); var2.three(); var3.two(); var3.three(); var4.one(); ((Blue) var1).one(); ((Yellow) var1).two(); } } ((Red) var2).three(); public class Green { public void one() { System.out.println("Green 1"); } public void three() { System.out.println("Green 3"); ((Yellow) var2).two(); ((Green) var4).three(); ((Yellow) var4).two(); } } The following variables are defined: Green var1 = new Blue(); Green var2 = new Red(); Blue var3 = new Yellow(); Object var4 = new Green()

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!