Question: Suppose that the following two classes have been declared: public class Car { public void m 1 ( ) { System.out.println ( car 1
Suppose that the following two classes have been declared:
public class Car
public void m
System.out.printlncar ;
public void m
System.out.printlncar ;
public String toString
return "vroom";
public class Truck extends Car
public void m
System.out.printlntruck ;
public void m
super.m;
public String toString
return super.toString super.toString;
Write a class MonsterTruck whose methods have the behavior below. Don't just printreturn the output; whenever possible, use inheritance to reuse behavior from the superclass.
Method OutputReturn
m
monster
m
truck
car
toString
"monster vroomvroom"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
