|
. int a[][] = new int[10][10]; D. int [][]a = new int[10][10]; E. int []a[] = new int[10][10];
49. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java? A. public class Fred{ public int x = 0; public Fred (int x){ this.x=x; } } B. public class fred{ public int x = 0; public Fred (int x){ this.x=x; } } C. public class Fred extends MyBaseClass, MyOtherBaseClass{ public int x = 0; public Fred(int xval){ x=xval; } } D. protected class Fred{ private int x = 0; private Fred (int xval){ x=xval; } } E. import java.awt.*; public class Fred extends Object{ int x; private Fred(int xval){ x = xval; } } 50. A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this? A. The variable should be marked public B. The variable should be marked private C. The variable should be marked protected D. The variable should have no special access modifier E. The variable should be marked private and an accessor method provided
答案及详细分析: 26。A、C、E 考察的知识点是比较基本类型与对象类型的不同之处,基本类型进行的是值比较,而对象类型进行的是地址比较,也就是对指向它们内存地址的指针进行比较。 27。E 在程序中实现字节与字符转换时,采用规范“ISO8859-1”是最适宜的方式。 28。B、D、E 移位操作只对整型有效,故不能选A;String类型并非数组,故不能用C所示方法取其中的某一位;B中的length方法返回字符串长度;D中trim方法返回字符串去掉其前后的空格后的新字符串;字符串可以用“+”进行合并。 29。E 回答本题时要细心阅读程序,注意“void Mistery(){}”并非构造函数,因为构造函数是没上一页 [1] [2] [3] [4] [5] [6] 下一页 |
|
|
|
|
|
|
|