Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. When you call this() inside a constructor, what are you doing? 2. Given the below Car class, update the default constructor so that it
1. When you call this() inside a constructor, what are you doing?
2. Given the below Car class, update the default constructor so that it calls the two argument constructor.
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 + " Model: " + model; } }
3. Next, override the equals method for the above Car class using the formula provided in class.
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