Question: 1 . To develop a vehicle class hierarchy in Java to demonstrate the concept of polymorphism. Step 1 : - Declare a super class called

1.To develop a vehicle class hierarchy in Java to demonstrate the concept of polymorphism.
Step 1:-Declare a super class called vehicle with data elements doors, wheels and seats.
Step 2:-Derive another class called car and invoke a function tostring0 to display the variables.
Step 3:-Derive another class calledmotorcycle with same data and method called setseats 0.
Step 4:-Declare another sub class called Truck with 2 constructors and finally assign values to variables.
Step 5:-In the main function, create an object for class motorcycle and display all details of sub classes through object.
 1.To develop a vehicle class hierarchy in Java to demonstrate the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!