Question
Write 3 Java classes called Car, OffroadCar and HybridCar.Demonstrate the concept of inheritance by making the Car class yoursuperclass. Give it the following attributes: int
Write 3 Java classes called Car, OffroadCar and HybridCar.Demonstrate the concept of inheritance by making the Car class yoursuperclass. 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 ifautomatic
____________
OffroadCClass
should be derived from the Car class and have the additionalattribute:
int wheel_diameter; // diameter of wheel in mm.
_____________________
HyCar
should be derived from the Car class and have the additionalattribute:
int batteries; // number of batteries in the car
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started