Question: Write 3 Java classes called Car, OffroadCar and HybridCar. Demonstrate the concept of inheritance by making the Car class your superclass. Give it the following
Write 3 Java classes called Car, OffroadCar and HybridCar. Demonstrate the concept of inheritance by making the Car class your superclass. Give it the following attributes:
int num_doors; // number of doors the car has
int hp; // the horse power of the car
boolean manual; // true if manual transmission, false if automatic
____________
OffroadCar Class
should be derived from the Car class and have the additional attribute:
int wheel_diameter; // diameter of wheel in mm.
_____________________
HybridCar
should be derived from the Car class and have the additional attribute:
int batteries; // number of batteries in the car
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
