|
ray of 50 string empty object? A. String [] a B. String a[] C. char a[][] D. String a[50] F. Object a[50]
15. Give the following java source fragement: //point x public class Interesting{ //do something } Which statement is correctly Java syntax at point x? A. import java.awt.*; B.package mypackage C. static int PI=3.14 D. public class MyClass{//do other thing…} E. class MyClass{//do something…}
11-15答案: 11。A 此题考查内部类及关键字“super”的用法。内部类不能与外部类同名。另外,当B继承A时,A中的构造函数是带参数的,B中缺省构造函数的函数体为空;而JAVA编译器会为空构造函数体自动添加语句“super();”调用父类构造函数,更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函数。 12。A 此关键字可以在两个线程同时试图访问某一数据时避免数据毁损。 13。C 当一个类中未显式定义构造函数时,缺省的构造函数是以类名为函数名,参数为空,函数体为空。虽然父类中的某一构造函数有字符串参数s,但是子类继承父类时并不继承构造函数,所以它只能使用缺省构造函数。故在第11行出错。 14。A、B 注意,题中问的是如何正确声明一个一维数组,并非实例化或者初始化数组 15。A、E X处可以是一个输入,包的定义,类的定义。由于常量或变量的声明只能在类中或方法中,故不能选择C;由于在一个文件中只能有一个public类,故不能选择D。
16. Give this class outline: class Example{ private int x; //rest of class body… } Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java? A. Change private int x to public int x B. change private int x to static int x C. Change private int x to protected int x D. change private int x to final int x
17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project “The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.” Which Data type would be used? A. Vector B. int C. String D. Color E. Date
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页 |
|
|
|
|
|
|
|