import java.util.Scanner; abstract class Vehicle { String wheels; abstract String noOfWheels(String a); void showWheels(){ System.out.println(wheels+" wheel vehicle"); } //write your own codes } class Car extends Vehicle { public String noOfWheels(String a){ wheels=a; return a; } //write your own codes } class Motorbike extends Vehicle { public String noOfWheels(String a){ wheels=a; return a; } //write your own codes } public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); Car ca=new Car();Motorbike mo=new Motorbike(); ca.noOfWheels(sc.next()); mo.noOfWheels(sc.next()); ca.showWheels(); mo.showWheels(); //write your own codes } }
时间: 2024-10-06 05:14:42