Question: Consider the following classes: public class Foo { public void method1() { System.out.println(foo 1); method2(); } public void method2() { System.out.println(foo 2); } } public
Consider the following classes: public class Foo { public void method1() { System.out.println("foo 1"); method2(); } public void method2() { System.out.println("foo 2"); } } public class Bar extends Foo { public void method2() { System.out.println("bar 2"); } public void method3() { System.out.println("bar 3"); } } public class Baz extends Foo { public void method1() { System.out.println("baz 1"); } public void method2() { System.out.println("baz 2"); method1(); } } public class Mumble extends Baz { public void method1() { super.method1(); System.out.println("mumble 1"); } public void method3() { System.out.println("mumble 3"); } } Suppose the following variables are defined: Foo var1 = new Bar(); Foo var2 = new Mumble(); Bar var3 = new Bar(); Baz var4 = new Baz(); Baz var5 = new Mumble(); Object var6 = new Baz();
Indicate on each line below the output produced by each statement shown. 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, write either runtime error or compiler error to indicate this. var1.method1(); var2.method1(); var3.method1(); var4.method1(); var5.method1(); var6.method1(); var1.method2(); var2.method2(); var3.method2(); var4.method2(); var5.method2(); var6.method2(); var3.method3(); var5.method3(); ((Bar) var1).method3(); ((Mumble) var4).method3(); ((Mumble) var5).method3(); ((Bar) var2).method3(); ((Baz) var2).method2(); ((Mumble) var6).method2();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
