SCJP认证套题解析之一
来源:优易学  2010-1-11 11:39:28   【优易学:中国教育考试门户网】   资料下载   IT书店

 

   1000 0000 0000 0000 0000 0000 0000 0000
B. 0000 0100 0000 0000 0000 0000 0000 0000<<5 gives
   1111 1100 0000 0000 0000 0000 0000 0000
C. 1100 0000 0000 0000 0000 0000 0000 0000>>5 gives
   1111 1110 0000 0000 0000 0000 0000 0000
D. 1100 0000 0000 0000 0000 0000 0000 0000>>5 gives
   0000 0110 0000 0000 0000 0000 0000 0000
(ac)
题目:使用"<<"和 ">>"操作符的哪些陈述是对的。
Java的移位操作符一共有三种,分别是”>>”,”>>>”,”<<”,执行的操作分别是有符号右移,无符号右移,左移,有符号右移的意思是说移入的最高位和原最高符号位相同,无符号右移是移入位始终补零,左移时最低位始终补零,最高位被舍弃。移位操作符另一个非常值得注意的特点是其右操作数是取模运算的,意思是说对于一个int型数据而言,对它移位32位的结果是保持不变而非变成零,即:a>>32的结果是a而不是0,同理,对long型数是对右操作数取64的模,a>>64==a;还有一点需要注意的是移位操作符”>>>”只对int型和long型有效,对byte或者short的操作将导致自动类型转换,而且是带符号的。
 
15、Which of the following range of int is correct?
A. -27 -- 27-1 
B. 0 – 232-1 
C. –215 -- 215-1 
D. –231 -- 231-1 
(d)
题目:int的取值范围是哪个。
int型是32位的。参看第一题的论述。
 
16、Which keyword should be used to enable interaction with the lock of an object? The flag allows exclusive access to that object.
A. transient
B. synchronized
C. serialize
D. static
(b)
题目:下面的哪些关键字通常用来对对象的加锁,该标记使得对对象的访问是排他的。
由于java是多线程的语言,多个线程可以”同时”访问同一数据区,而在处理某些数据时不希望其它的线程修改那些数据的值或者某些操作是不可打断的,要做到这个,可以使用synchronized关键字声明这一点。
 
17、Which is the return type of the method main()?
A. int
B. void
C. boolean
D. static
(b)
题目:main()方法的返回类型是什么?
在java中,程序运行的入口就是main()方法,它必须是这样的形式:public static void main(String args[])。但是严格来讲这个题目的答案还可以加上a和c,因为并没有限定是程序入口的main()方法,而main()方法是可以重载的。一般意义上的main()当然就是指我们刚开始所说的main()方法了。
 
18、Given the following code:
if (x>0) { System.out.println("first"); }
else if (x>-3) { System.out.println("second"); }
     else { System.out.println("third"); }
Which range of x value would print the string "second"?
A. x > 0
B. x > -3
C. x <= -3
D. x <= 0 & x > -3
(d)
题目:给出下面的代码:

x的取值在什么范围内时将打印字符串"second"。
x>0时打印"first",x>-3&&x<=0时打印"second",x<=-3时打印"third"。
这个题目没有什么难的,只要理解if语句的语法就可以了。
 
19、Given the following expression about TextField which use a proportional pitch font. 
TextField t = new TextField("they are good",40);
Which statement is true?
 
A. The displayed string can use multiple fonts.
B. The maximum number of characters in a line will be 40.
C. The displayed width is exactly 40 characters.

上一页  [1] [2] [3] [4] [5] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
热门课程培训