问题 问答题

接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 ______________MyInterface { public static int NUM=100; public abstract void print(); } public class ClassName___________MyInterface { public void print() { System.out.println(NUM); } public static void main(String args[]) {__________________________ obj .print(); } }

答案

参考答案:

解析:interface implements ClassName obj=new ClassName(); 本题主要考查接口、如何生成一个类的对象知识。解答本题的关键是熟练掌握接口、如何生成一个类的对象知识。在本题中,interface MyInterface语句中的interface的功能是声明接口MyInterface,public class ClassName implements MyInterface语句中的implements的功能是声明ClassName并实现MyInterface接口,ClassName obj=new ClassName();语句的功能是生成 ClassName型的对象obj。

读图填空题
单项选择题