Question: Consider the following two classes: public class Car { public void m10) { System.out.println($); } public void m2() { System.out.println(#); } public String toString() {
Consider the following two classes: public class Car { public void m10) { System.out.println("$"); } public void m2() { System.out.println("#"); } public String toString() { return "vroom"; } public class Truck extends Car{ public void m10 { System.out.println("@"); } } And assuming that the following variables have been declared: Car mycar = new Car(); Truck mytruck = new Truck0; What is the output from the following statements? System.out.println(mycar); mycar.m10: caram 20 And assuming that the following variables have been declared: Car mycar = new Car(); Truck mytruck = new Truck(); What is the output from the following statements? System.out.println(mycar); mycar.m10; mycar.m2); System.out.println(mytruck); mytruck.m10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
