[sun认证java程序员]SUN认证Java2程序员考试(SCJP) 试题解析(3)
【shitiku.jxxyjl.com--JAVA认证试题集锦】
what happens when you try to compile and run the following application? choose all correct options.1. public class z {
2. public static void main(string[] args) {
3. new z();
4. }
5.
6. z() {
7. z alias1 = this;
8. z alias2 = this;
9. synchronized(alias1) {
10. try {
11. alias2.wait();
12. system.out.println(“done waiting”);
13. }
14. catch (interruptedexception e) {
15. system.out.println(“interr
upted”);
16. }
17. catch (exception e) {
18. system.out.println(“other exception”);
19. }
20. finally {
21. system.out.println
(“finally”);
22. }
23. }
24. system.out.println(“all done”);
25. }
26. }
a. the application compiles but doesn’t print anything.
b. the application compiles and print “done waiting”
c. the application compiles and print “finally”
d. the application compiles and print “all done”
e. the application compiles and print “interrupted”
解答:a
点评:在java中,每一个对象都有锁。任何时候,该锁都至多由一个线what happens when you try to compile and run the following application? choose all correct options.
1. public class z {
2. public static void main(string[] args) {
3. new z();
4. }
5.
6. z() {
7. z alias1 = this;
8. z alias2 = this;
9. synchronized(alias1) {
10. try {
11. alias2.wait();
12. system.out.println(“done waiting”);
13. }
14. catch (interruptedexception e) {
15. system.out.println(“interr
upted”);
16. }
17. catch (exception e) {
18. system.out.println(“other exception”);
19. }
20. finally {
21. system.out.println
(“finally”);
22. }
23. }
24. system.out.println(“all done”);
25. }
26. }
a. the application compiles but doesn’t print anything.
b. the application compiles and print “done waiting”
c. the application compiles and print “finally”
d. the application compiles and print “all done”
e. the application compiles and print “interrupted”
解答:a
点评:在java中,每一个对象都有锁。任何时候,该锁都至多由一个线ent(te),注册的listener将不会被唤醒。
scjp考试中的几点注意:
● 深刻理解面向对象的思想
java是一种纯粹的面向对象的程序设计语言。在正式使用java做开发之前,必须将我们的思维方式转入一个彻底的面向对象的世界。做不到这一点,就无法体会java语言的精髓,写不出地道的java程序。当然,你也无法彻底理解java中的基本概念和他们之间的联系与区别,如例题3、例题5。你可以学到java的语法规则,却不能看到java的灵魂。
● 对概念细节的精确把握
通过例题我们可以看到,scjp的考察点相当细致。如例题1、2、4、7、8。所以只有对java的概念、语法、规则了然于心,才能在考场上应对自如。
● 适量的练习
程序设计是一项实践性很强的技术。只有上机实践,才能使课本中的理论、头脑中的思想通过你的双手成为一行行代码,完成规定的目标。虽然scjp考试不考操作与编程,但有大量的程序阅读,如例题3、4、9、10。如果你自己写过许多代码的话,这种题就是小菜一碟。
● 广泛的交流
善于交流是优秀程序员必备的技能,也是你解决疑难,提高水平的捷径。国内外有很多与java认证相关的优秀网站和论坛,都是学习java的宝库。同时,一些很棒的模考软件,如jxam、jtest、 javacert等,以及著名的模考题如marcusgreen的三套题均可以找到。
本文来源:https://shitiku.jxxyjl.com/javarenzhengshitijijin/6349.html
-
java二级考试历年真题_JAVA认证历年真题:SCJP认证套题解析详细阅读
41、which of the following statements are legal?a long l = 4990;b int i = 4l;c float f = 1 1;d double d = 34 4;e double t = 0 9f (ade)题目:下面的哪些声明是...
-
java 将日期转化为格林时间|JAVA题库:格林模拟试题二(下)(3)详细阅读
question 36)which of the following are java key words1)double2)switch3)then4)instanceofquestion 37)what will be output by the following line?system ou...
-
java 将日期转化为格林时间_JAVA题库:格林模拟试题二(下)(1)详细阅读
question 31)what will happen when you attempt to compile and run the following codeimport java io *;class base{ public void amethod()throws filenot...
-
java 将日期转化为格林时间|JAVA题库:格林模拟试题二(下)(2)详细阅读
question 33)what will happen when you attempt to compile and run this code demonstration of event handlingimport java awt *;import java awt event *;p...
-
[java 将日期转化为格林时间]JAVA题库:格林模拟试题三(上)(3)详细阅读
question 10)which of the following statements are true?1) a byte can represent between -128 to 1272) a byte can represent between -127 to 1283) a byte...
-
java二级考试历年真题|JAVA认证历年真题:SCJP认证套题解析详细阅读
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 解析 短整型的数...
-
[sun认证java程序员]SUN认证Java2程序员考试(SCJP) 试题解析(3)详细阅读
what happens when you try to compile and run the following application? choose all correct options 1 public class z { 2 public static void ma...
-
【java 将日期转化为格林时间】JAVA题库:格林模拟试题二(下)(4)详细阅读
question 40)which of the following statements are correct?1) if multiple listeners are added to a component only events for the last listener added wi...
-
java 将日期转化为格林时间_JAVA题库:格林模拟试题二(上)(2)详细阅读
question 4)what will happen when you attempt to compile and run this code?class base{ abstract public void myfunc(); public void another...
-
java二级考试历年真题|JAVA认证历年真题:SCJP考试真题和解析详细阅读
例题1: choose the three valid identifiers from those listed below a idolikethelongnameclass b $byte c const d _ok e 3_case 解答:a, b, d 点评...