Write a usevehicle class to instantiaate the two vehicle


Creat a class named Vehicle that acts as a superclass of vehicle types. The Vehicle class contains private variable fo rthe number of wheels and the average number of miles per gallon. The Vehicle class also contains a constructor with interger arguments for the number of wheels and average miles per gallon, and toString () method that returns a String containing these values. Save as Vehicle.java

Create two subclasses, car and MotorCycle, that extend the Vehicle class. Each subclass contains a constructor that accepts the miles per gallon value as an argument and forces and number of wheels to the appropriate value 2 for a MotorCycle and 4 for a Car. Sace a Car.java and MortCycle.java

Write a UseVehicle class to instantiaate the two Vehicle objects and print the objects values. Save as UseVehicle.java

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a usevehicle class to instantiaate the two vehicle
Reference No:- TGS01249852

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)