Question
Write a VehicleDemo.java class that does the following: 1- Creates an instance of a Car and an instance of an Airplane class. 2- Assigns values
Write a VehicleDemo.java class that does the following: 1- Creates an instance of a Car and an instance of an Airplane class. 2- Assigns values to the name, max_speed and number_of_cylinders instance variables of the Car object and the name, max_speed and number_of_engines instance variables of the Airplane object. 3- Calls all the methods of the Car and Airplane objects that return the values of their instance variables and prints the results. 4- Calls the runningCost(5) of the Car and Airplane objects and prints the result. 5- Calls the maintenanceCost (30.0) of the Car and maintenanceCost (250.0) of the Airplane objects and prints the result. 6- Defines a reference variable of type Vehicle and assigns it to an instance of a Car class. Example: Vehicle v1 = new Car(); 7- Prints v1. Notice whether the toString() method of the Vehicle class is called or the toString() method of the Car class. Explain why it has been the case. In Object Oriented paradigm, what is this called? need coding in java for all the parts
Step by Step Solution
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