全国计算机与信息技术资格认证.docVIP

  • 8
  • 0
  • 约9.75千字
  • 约 9页
  • 2020-06-15 发布于湖北
  • 举报
全国计算机与信息技术资格认证 高级软件工程师(JAVA语言程序设计)2 1. Which of the following range of short is correct? A. -27 -- 27-1 B. 0 -- 216-1 C. ?215 -- 215-1 D. ?231 -- 231-1 翻译下面哪些是short型的取值范围。 答案 C 解析 短整型的数据类型的长度是16 bits,有符号。另外需要说明的是java中所有的整(Integral)数(包括byte,short,int,long)全是有符号的。 2. Which declarations of identifiers are legal? A. $persons B. TwoUsers C. *point D. this E. _endline 翻译下面哪些是合法的标识符。 答案 A,B,E 解析 Java的标识符可以以一个Unicode字符,下滑线(_),美元符($)开始,后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字。 3. Which statement of assigning a long type variable to a hexadecimal value is correct? A. long number = 345L; B. long number = 0345; C. long number = 0345L; D. long number = 0x345L 翻译哪些是将一个十六进制值赋值给一个long型变量。 答案 D 解析 十六进制数以0x开头,long型数以L(大小写均可,一般使用大写,因为小写的l和数字1不易区分)。 4.Which of the following fragments might cause errors? A. String s = Gone with the wind; String t = good ; String k = s + t; B. String s = Gone with the wind; String t; t = s[3] + one; C. String s = Gone with the wind; String standard = s.toUpperCase(); D. String s = home directory; String t = s - directory; 翻译下面的哪些程序片断可能导致错误。 答案B,D 解析 A:String类型可以直接使用+进行连接运算。 B:String是一种Object,而不是简单的字符数组,不能使用下标运算符取其值的某个元素,错误。 C:toUpperCase()方法是String对象的一个方法,作用是将字符串的内容全部转换为大写并返回转换后的结果(String类型)。 D:String类型不能进行减(-)运算,错误。 5. Which are syntactically valid statement at// point x? class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } } A. i = m; B. i = b; C. i = p.a; D. i = p.change(30); E. i = t.b. 翻译在// point x处的哪些申明是句法上合法的。 答案D,E 解析 A:m没有被申明过,不能使用。 B:虽然b是类Teacher的public成员变量,但是在静态方法中不能使用类中的非静态成员。 C:a是类Person的private成员,在类外不能直接引用。 D:change(int m)方法是public方法,并且返回一个int型值,可以通过类的实例变量p引用并赋值给一个int型变量。 E:b是类Teacher的public成员变量,且是int型,可以通过类的实例变量t引用并赋值给一个int型变量。 6. Which layout manager is used when the frame is resized the buttonss position in the Frame might be changed

文档评论(0)

1亿VIP精品文档

相关文档