Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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