(Java) Q 1,2 ANSWER BOTH PART 1 AND 2!!! Explain the answer step-by-step and include verbal explanation. Thank you! PART 1: 1. Given the below Car class, write a child class of Car named Tesla. The Tesla class has an additional private boolean variable named autoPilotEnabled. It also has two constructors - a default constructor and a three argument constructor. Both constructors call the appropriate constructors of the parent class. Tesla also has a getter and setter for the autoPilotEnabled variable. Finally, it has a toString method that calls the toString of Car, as well as concatenating the autoPilotEnabled variable. public class Car { private String make; private String model; public Car() { make = "Make unknown"; model = "Model unknown"; } public Car(String make, String model) { this.make = make; this.model = model; } public String getMake() { return make; } public String getModel() { return model; } public void setMake(String make) { this.make = make; } public void setModel(String model) { this.model = model; } public boolean timeForService(int currMileage) { if (currMileage > 10000) { return true; } return false; } @Override public String toString() { return "Make: " + make + "\nModel: " + model; } } PART 2: Next, override the timeForService method for the Tesla class to return true if the currMileage is greater than 15000.
(Java)
Q 1,2
ANSWER BOTH PART 1 AND 2!!!
Explain the answer step-by-step and include verbal explanation. Thank you!
PART 1:
1. Given the below Car class, write a child class of Car named Tesla. The Tesla class has an additional private boolean variable named autoPilotEnabled. It also has two constructors - a default constructor and a three argument constructor. Both constructors call the appropriate constructors of the parent class. Tesla also has a getter and setter for the autoPilotEnabled variable. Finally, it has a toString method that calls the toString of Car, as well as concatenating the autoPilotEnabled variable.
public class Car {
private String make;
private String model;
public Car() {
make = "Make unknown";
model = "Model unknown";
}
public Car(String make, String model) {
this.make = make;
this.model = model;
}
public String getMake() {
return make;
}
public String getModel() {
return model;
}
public void setMake(String make) {
this.make = make;
}
public void setModel(String model) {
this.model = model;
}
public boolean timeForService(int currMileage) {
if (currMileage > 10000) {
return true;
}
return false;
}
@Override public String toString() {
return "Make: " + make + "\nModel: " + model;
}
}
PART 2:
Next, override the timeForService method for the Tesla class to return true if the currMileage is greater than 15000.
![](/static/compass_v2/shared-icons/check-mark.png)
I updated the code and also provide the output screenshot and code as per your requirement
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)