Untitled
unknown
plain_text
a year ago
1.3 kB
3
Indexable
Never
public class Vehicles { String makeby; int makingyear; Vehicles(String makeby,int makingyear){ this.makeby=makeby; this.makingyear=makingyear; } void displayInfo(){ System.out.println("make:" +makeby); System.out.println("Year:"+makingyear); } } public class Car extends Vehicles { int numberofdoors; Car(String makeby, int makingyear, int numberofdoors){ super(makeby,makingyear); this.numberofdoors=numberofdoors; } void displayInfo(){ System.out.println("car Information"); super.displayInfo(); System.out.println("numberofdoors:" +numberofdoors); } } class Motorcycle extends Vehicles { boolean numofdoor; Motorcycle(String makeby,int makingyear,boolean numofdoor){ super(makeby,makingyear); this.numofdoor=numofdoor; } void displayInfo(){ System.out.println("Motorcycle Information"); super.displayInfo(); System.out.println(numofdoor); } } public class Main { public static void main(String[] args) { Car car = new Car("Toyota", 2022, 4); Motorcycle motorcycle=new Motorcycle("Harley-Davidson", 2021,true); car.displayInfo(); motorcycle.displayInfo(); } }