SCJP真题库更新八
QUESTION 31
Exhibit:
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 )
参考大纲:Java语言基础 — 对象的存储
QUESTION 32
A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar.
Which three, taken independently, will allow the developer to use the Paper class
while compiling the Book class? (choose three)
A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar
B. The JAR file is located at $/JAVA_HOME/jre/lib/ext/myLib.jar.
C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar/Paper,Class.
D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac
-cp /foo/myLib.jar/Paper Book java.
F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d
/foo/myLib.jar Book java.
G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java
Answer: ( B, D, G )
Javac -d 指定编译后的文件存放的位置
Javac –cp 指定编译时需要用到的类文件位置
参考大纲:Java语言基础 — Classpath设定
QUESTION 33
Given the exhibit:
Which statement is true about the object referenced by snoog, smooch 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 colletion
D. Only the object referenced by smooch is eligible for garbage collection
E. The objects referenced by smooch and booch are eligible for garbage collection
Answer: ( E )
孤岛参照法,所以三个对象都被回收。
参考大纲:垃圾回收机制
QUESTION 34
Given the exhibit:
and the command line invocation
java Certkiller5 a b c
what is the result?
A. a b
B. b c
C. a b c
D. Compilation fails
E. An exception is thrown at runtime
Answer: ( B )
数组下表从0开始
参考大纲:Java语言基础
QUESTION 35
Given the exhibit:
What is the result?
A. r, t, t
B. r, e, o,
C. Compilation fails
D. An exception is thrown at runtime
Answer: ( C )
第13行错误,check不是boolean类型
参考大纲:流程控制