Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following three class declarations public class Vehicle private Str

ID: 3827958 • Letter: C

Question

Consider the following three class declarations public class Vehicle private String registrationNumber; public vehicle (String rego) registration Number rego public string getRegistrationNumber return registrationNumber; public class Car extends Vehicle int passengers public car(string rego, int pass) super rego passengers pass public int get Passengers return passengers public class Truck extends Vehicle int tons public Truck (String rego, int tons) super rego this tons tons public int getTons return tons

Explanation / Answer

Here is the generic method to print registration number for Vehicle, Car, Truck

void printRego(Vehicle v)
{
System.out.println(v.getRegistrationNumber());
}