Question: Question 16 4 poin Write a JAVA code to implement a class named Vehicle, and its subclass called Car. The details of the classes are

Question 16 4 poin Write a JAVA code to implement a class named Vehicle, and its subclass called Car. The details of the classes are described in the following UML diagram Vehicle -id : int +Vehicle +Vehicle(id : int) +getID : int +setId(id : int) : void +toString(): String Car -brand : String -color: String +Car(id : int, brand : String, color : String) +toString(): String For Vehicle class: - In the constructor Vehicle(id: int), use this keyword to initialize the attribute id. - The toString() should override the toString() of the object class. It should return the id of the vehicle. For example: Vehicle (id = 1001) For Car class: - Use super keyword to invoke the superclass constructor to pass the id. - Use this keyword to initialize the attributes brand and color. Override the Loslring() method to return the id, brand and color. Use super keyword to invoke the Lostring() of the super class for the id. For example: car : Vehicle (id = 1001), brand = Toyota, color = Red
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
