Inheritance problems
- Using this, add a no-argument constructor to the followingclass Vehicle.
public class Vehicle
{
private String maker;
private int makeYear;
public Vehicle(String s, int i)
{
maker = s;
makeYear = i;
};
//NO-ARGUMENTS CONSTRUCTOR
}
- Create a class Car that inherits from Vehicle. Add a privateString model and two constructors (with and withoutarguments).
public class Car __________________________________
{
//Add model variable
//Add constructor with 3 arguments
//Add constructor with no arguments
}
- Given the classes Car and Vehicle above, whatwould be the output for the following code?
public static void main(String [] args) {
Car c = new Car();
Vehicle v = new Vehicle();
System.out.println(v instanceof Car);
System.out.println(c instanceof Vehicle);
System.out.println(v.getClass() ==
OR
OR