ou need to write the complete code as mentioned below: i) The main class with necessary codes. ii) The subclass with necessary codes. iii) The Test class with necessary codes
Write a class named Vehicle with vehicleType, manufactureYear(int) and cost(double) as private data fields. [Hint: VehcleType could be "truck", "4WD", "Bus"] . Add a constructor with any two parameters of the superclass. Write a class named Car which inherits the Vehicle class. Add a non-static private string variable called companyName. Add a constructor in the subclass and a toString() method that prints the Car's data fields in the order VehicleType, manufactureYear, companyName [Hint: Add a toString( ) method in the superclass as well]. Create objects of Vehicle and Car class. Can the object of Vehicle class be stored in an object of Car Class? If yes, write the code. If No, Explain why?
***Student Instruction ***
You need to write the complete code as mentioned below:
i) The main class with necessary codes.
ii) The subclass with necessary codes.
iii) The Test class with necessary codes.
Step by step
Solved in 2 steps with 2 images