Question: Java Program Practice Inheritance Problem Assuming that the following classes have been defined: public class Block extends Truck public void methodl() { System.out.println(Block 1); }

Java Program

Java Program Practice Inheritance Problem Assuming that the following classes have been

defined: public class Block extends Truck public void methodl() { System.out.println("Block 1");

Practice Inheritance Problem Assuming that the following classes have been defined: public class Block extends Truck public void methodl() { System.out.println("Block 1"); } public void method3() { System.out.println("Block 3"); > public class Doll extends Ball { public void methodl() { System.out.println("Doll 1"); 1 public void method2() { System.out.println("Doll 2"); public class Truck extends Ball { public void method2() { System.out.println("Truck 2"); super.method2(); method3(); public void method3() { System.out.println("Truck 3"); public class Ball public void method2() { System.out.println("Ball 2"); } public void methods() System.out.println("Ball 3"); And assuming the following variables have been defined: Ball varl - new Truck(); Doll var2 - new Doll(); Ball var3 - new Block(); Object var4 - new Ball(); Truck var5 - new Block(); Ball var6 - new Doll(); 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 followed by "c". If the statement causes an error, fill in the right-hand column with either the phrase "compiler error" or "runtime error" to indicate when the error would be detected. Statement Output var1.method10: var2.method 10; vart.method2(): var2.method2(); var3.method20); var4.method20); vars.method2(); var1.method30); var2.method30: var3.method30: vart.method30); var5. method3(); ((Doll var3).method10); ((Block)var5).method10: ((Truck)var3).method 10; ((Truck)var3),method3(); ((Block)var6).method30: ((Ball)var4).method2(); ((Truck)var4).method3(); ((Dollyvar6).method3()

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!