Inheritance Problems Using Add Argument Constructor Following Class Vehicle Public Class V Q37020537

Inheritance problems

  1. 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

}

  1. 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

}

  1. 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

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.