Question: Create a Vehicle super class and create two subclasses Car and Truck. Extend the two subclasses to the super class to inherit the member
Create a Vehicle super class and create two subclasses Car and Truck. Extend the two subclasses to the super class to inherit the member variables and methods. Create a Create Vehicle class with the main method to create objects of the two sub classes. Create a class 'Vehicle' with states and actions that are common to all vehicles Member variables int noOfSeats; Member variables String color; int noOfCylinders setnoOfSeats(); toString(); Vehicle Class(super class) Member methods setColor(); getColor(); Car Class(sub class) set noOfCylinders(); get noOfCylinders(); toString(); Extends Member methods setColor();[Inherits from super class] getColor():[Inherits from super class] set noOfCylinders();[Inherits from super class] get noOfCylinders();[Inherits from super class] Extends Truck Class(sub class) Member variables int towingCapacity Member methods setColor();[Inherits from super class] getColor():[Inherits from super class] set noOfCylinders();[Inherits from super class] get noOfCylinders();[Inherits from super class] toString();
Step by Step Solution
3.40 Rating (166 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
