Question: [JAVA] Study Guide Problems 6. Inheritance and Polymorphism Consider the following classes: public class Blue extends Green { public void one() { System.out.println(Blue 1); super.one();

[JAVA] Study Guide Problems

6. Inheritance and Polymorphism

Consider the following classes:

public class Blue extends Green { public void one() { System.out.println("Blue 1"); super.one(); } }

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"); } }

public class Green { public void one() { System.out.println("Green 1"); } public void three() { System.out.println("Green 3"); } }

The following variables are defined: Green var1 = new Blue(); Green var2 = new Red(); Blue var3 = new Yellow(); Object var4 = new Green();

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 Output

var1.one(); ________________________

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(); ________________________

((Yellow) var2).two(); ________________________

((Green) var4).three(); ________________________

((Yellow) var4).two(); ________________________

Link to Source PDF:

https://www.dropbox.com/s/1lrjfjs38plzska/Practice_Final_Exam.pdf?dl=0

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!