Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

How can we benefit from them?

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago