Question: 1 . To develop a vehicle class hierarchy in Java to demonstrate the concept of polymorphism. Step 1 : - Declare a super class called
To develop a vehicle class hierarchy in Java to demonstrate the concept of polymorphism.
Step :Declare a super class called vehicle with data elements doors, wheels and seats.
Step :Derive another class called car and invoke a function tostring to display the variables.
Step :Derive another class calledmotorcycle with same data and method called setseats
Step :Declare another sub class called Truck with constructors and finally assign values to variables.
Step :In the main function, create an object for class motorcycle and display all details of sub classes through object.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
