Question 24
11. class Snoochy {
12. Boochybooch;
13. public Snoochy() { booch = new Boochy(this); }
14. }
15.
16. class Boochy {
17. Snoochy snooch;
18. public Boochy(Snoochy s) { snooch = s; }
19. }
And the statements:
21. public static void main(String[] args) {
22. Snoochy snoog = new Snoochy();
23. snoog = null;
24. // more code here
Copyright Tarena Corporation,2008.All rights reserved
25. }
Which statement is true about the objects referenced by snoog,
snooch, and booch immediately after line 23 executes?
A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage
collection.
C. Only the object referenced by snoog is eligible for garbage
collection.
D. Only the object referenced by snooch is eligible for garbage
collection.
E. The objects referenced by snooch and booch are eligible for garbage
collection.
Answer: EQuestion 30
Given:
11. public class Commander {
12. public static void main(String[] args) {
13. String myProp = /* insert code here */
14. System.out.println(myProp);
15. }
16. }
and the command line:
java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper?
(Choose two.)
A. System.load("prop.custom");
B. System.getenv("prop.custom");
C. System.property("prop.custom");
D. System.getProperty("prop.custom");
E. System.getProperties().getProperty("prop.custom");
Answer: DEQuestion 35
A UNIX user named Bob wants to replace his chess program with a
new one, but he is hot sure where the old one is installed. Bob is
currently able to run a Java chess program starting from his home
directory /home/bob using the command:
java -classpath /test:/home/bob/downloads/* .jar games.Chess
Bob’s CLASSPATH is set (at login time) to:
/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/* .jar
What is a possible location for the Chess.class file?
A. /test/Chess.class
B. /home/bob/Chess.class
C. /test/games/Chess.class
D. /usr/lib/games/Chess.class
E. /home/bob/games/Chess.class
F. inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
G. inside jarfile /home/bob/downloads/Games.jar (with a correct
manifest)
Answer: C小弟快考scjp了,有些题还没弄懂,请高手指教,答案已给,求解释
11. class Snoochy {
12. Boochybooch;
13. public Snoochy() { booch = new Boochy(this); }
14. }
15.
16. class Boochy {
17. Snoochy snooch;
18. public Boochy(Snoochy s) { snooch = s; }
19. }
And the statements:
21. public static void main(String[] args) {
22. Snoochy snoog = new Snoochy();
23. snoog = null;
24. // more code here
Copyright Tarena Corporation,2008.All rights reserved
25. }
Which statement is true about the objects referenced by snoog,
snooch, and booch immediately after line 23 executes?
A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage
collection.
C. Only the object referenced by snoog is eligible for garbage
collection.
D. Only the object referenced by snooch is eligible for garbage
collection.
E. The objects referenced by snooch and booch are eligible for garbage
collection.
Answer: EQuestion 30
Given:
11. public class Commander {
12. public static void main(String[] args) {
13. String myProp = /* insert code here */
14. System.out.println(myProp);
15. }
16. }
and the command line:
java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper?
(Choose two.)
A. System.load("prop.custom");
B. System.getenv("prop.custom");
C. System.property("prop.custom");
D. System.getProperty("prop.custom");
E. System.getProperties().getProperty("prop.custom");
Answer: DEQuestion 35
A UNIX user named Bob wants to replace his chess program with a
new one, but he is hot sure where the old one is installed. Bob is
currently able to run a Java chess program starting from his home
directory /home/bob using the command:
java -classpath /test:/home/bob/downloads/* .jar games.Chess
Bob’s CLASSPATH is set (at login time) to:
/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/* .jar
What is a possible location for the Chess.class file?
A. /test/Chess.class
B. /home/bob/Chess.class
C. /test/games/Chess.class
D. /usr/lib/games/Chess.class
E. /home/bob/games/Chess.class
F. inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
G. inside jarfile /home/bob/downloads/Games.jar (with a correct
manifest)
Answer: C小弟快考scjp了,有些题还没弄懂,请高手指教,答案已给,求解释
解决方案 »
- java String 转成 byte 的问题
- 大虾们,JAVA中怎么实现记事本中的撤消功能,要自己实现还是JAVA提供现成的类,谢谢!
- JAVA的返射机制
- 帮忙
- 哪位大哥帮忙解释下aes算法 在linux服务器上解密时的出现报错问题,困搅N天了,急急急啊?
- 运行中出现这种错误,JSP调用EJB,用的是STRUTS加EJB架构,谢谢各位大哥
- 我用jbuilder做了个程序,并用jbuilder生成.exe形式,但运行后程序小图标是java虚拟机的销图标,如何换自己的?
- 那里有class12.jar下载!谢谢!急呀!
- 谁能说出Applet中init()的真正作用?100大洋
- 哪位高手能给介绍一点关于Java初级方面的书籍,由于是新手只能给22分望大家谅解!!
- 我用Java通过禁用内外网卡,做了一个摆渡工具,但效率不高
- 论坛帖子拖尾!急
第二题:-Dprop是用来设置系统变量的,所以要用System.getProperty方法。System.load是用来载入动态库的,System.getenv方法没有参数
第三题:考的是-classpath的用法。javaAPI中有一句话:Specifying -classpath or -cp overrides any setting of the CLASSPATH environment variable. 也就是说如用在运行程序时用了-classpath,原来系统载入的CLASSPATH就被覆盖了,所以B,D,E,F.而且运行是又指明了包明,所以A是不的。C是对的,G也应该是对的。不明白为什么答案只有C?