OCJP(1Z0-851) 模拟题分析(五)

Exam : 1Z0-851Java Standard Edition 6 Programmer Certified Professional Exam以下分析全都是我自己分析或者参考网上的,定有疏漏,还请大家对我的分析提出质疑。QUESTION 134Given:11. class Snoochy {12. Boochy booch;13. pub
摘要由CSDN通过智能技术生成

Exam : 1Z0-851

Java Standard Edition 6 Programmer Certified Professional Exam

以下分析全都是我自己分析或者参考网上的,定有疏漏,还请大家对我的分析提出质疑。



QUESTION 134

Given:
11. class Snoochy {
12. Boochy booch;
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
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: E

23行结束,snooch 和booch都没引用任何对象,可以被垃圾回收器回收。


QUESTION 135
Given:
3. public class Batman {
4. int squares = 81;
5. public static void main(String[] args) {
6. new Batman().go();
7. }
8. void go() {
9. incr(++squares);
10. System.out.println(squares);
11. }
12. void incr(int squares) { squares += 10; }
13. }
What is the result?
A. 81
B. 82
C. 91
D. 92
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: B

一定要记得java的参数传递全部都是引用~~不变哦~~


QUESTION 136
Given classes defined in two different files:
1. package util;
2. public class BitUtils {
3. private static void process(byte[] b) {}
4. }
1. package app;
2. public class SomeApp {
3. public static void main(String[] args) {
4. byte[] bytes = new byte[256];
5. // insert code here
6. }
7. }
What is required at line 5 in class SomeApp to use the process method of BitUtils?
A. process(bytes);
B. BitUtils.process(bytes);
C. app.BitUtils.process(bytes);
D. util.BitUtils.process(bytes);
E. import util.BitUtils.*; process(bytes);
F. SomeApp cannot use the process method in BitUtils.
Answer: F

process的访问修饰符不允许这样做


QUESTION 137
A UNIX user named Bob wants to replace his chess program with a new one, but he is not 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

围棋程序问题,重复的题目~~考察路径classpath的。/home/bob/downloads/*.jar的写法无效~~


QUESTION 138

Click the Exhibit button. What is the output of the program shown in the exhibit?



A. 300-100-100-100-100
B. 300-300-100-100-100
C. 300-300-300-100-100
D. 300-300-300-300-100
Answer: B

参数传递传的是引用~~


QUESTION 139

Given the following directory structure: 

bigProject

 |--source

 | |--Utils.java

 |

 |--classes

 |-- 

And the following

command line invocation: javac -d classes source/Utils.java Assume the current directory is bigProject,
what is the result?
A. If the compile is successful, Utils.class is added to the source directory.
B. The compiler returns an invalid flag error.
C. If the compile is successful, Utils.class is a
  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值