c++或者c#编程

来源:百度知道 编辑:UC知道 时间:2024/06/18 15:08:46
Create an Interface Vehicle with abstract method noOfDoors with return type int and implement a Car with noOfDoors returning 4. The following code should work:
Vehicle vehicle = new Car();
System.out.println (“” + vehicle.noOfDoors());

求题目意思和答案...

你好:
题目的意思是:
(1)定义一个接口Vehicle,接口里定义一个抽象方法noOfDoors(),这个方法的返回值是int类型,
(2)然后定义一个car类在这个类中实现这个接口
(3)定义一个car类的对象,通过对象调用noOfDoors(),返回值是4