Question: Create class Car with below attributes: make model passengerCapacity onRoadPrice - Create another class CarDemo which has main method. Create another method getBestCar in

Create class Car with below attributes: make model passengerCapacity onRoadPrice - Create

Create class Car with below attributes: make model passengerCapacity onRoadPrice - Create another class CarDemo which has main method. Create another method getBestCar in this class which will take four car objects and additional parameter as compareType. Value of this parameter can be 'c' or 'p', where 'c' stands for capacity of passengers and 'p' stands for on road price. This method will return make and model name for highest value of 'c' or 'p' (with - character in between. E.g for make - Hyundai and model - santro, method should return "Hyundai-santro"). Create four objects of Car class in main method and drive it through getBestCar method. Use inheritance to code this program.

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 Programming Questions!