Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write 3 Java classes called Car, OffroadCar and HybridCar. Demonstrate the conce

ID: 3904334 • Letter: W

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 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

Explanation / Answer

public class Car { 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 } class OffroadCar extends Car { int wheel_diameter; // diameter of wheel in mm. } class HybridCar extends Car { int batteries; // number of batteries in the car }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote