Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA Goal: Learn how to how to extend classes. Assignment: Imagine you have a superclass named Vehicle that: has two private data fields: maxSpeed (
JAVA
Goal: Learn how to how to extend classes.
Assignment: Imagine you have a superclass named Vehicle that:
has two private data fields: maxSpeed of type double and color of type String;
provides both a default constructor Vehicle and a parameterized constructor Vehicledouble maxSpeed, String color;
provides public getters and setters getMaxSpeed, getColor, setMaxSpeed, setColor.
Your task is to create a public subclass named Car that extends the Vehicle class. This subclass should introduce an additional private attribute named make of type String to represent the car's make eg Toyota, Ford
In the Car subclass:
Include a constructor CarString make, int speed, String color
Include a public getter and setter for the make attribute.
write your code below
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