QUESTION 76
A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command: Java games.cards.Poker
What allows the user to do this?
A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java
B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include
/stuff/java/*.jar
C. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include
/stuff/java/Poker.jar
D. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include
/stuff/java
E. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include
/stuff/java/*.jar
F. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include
/stuff/java/Poker.jar
Answer: ( C )
classpath中须明确写明poker.jar,不能用*.jar
QUESTION 77
Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
A. n = 100;
B. i.setX(100);
C. o.getY().setX( 100 );
D. i = new Inner(); i.setX( 100 );
E. 0.setY ( i ); i = new Inner(); i.setX ( 100 );
F. i = new Inner (); i.setX( 100 ); o.setY( i );
Answer: ( B, C, F )
根据内存关系可知
QUESTION 78
Given a class Repetition:
And given another class Demo:
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"
A. import utils.*;
B. static import utils.*;
C. import utils.Repetition.*;
D. static import utils.Repetition.*;
E. import utils.Repetition.twice();
F. import static utils.Repetition.twice;
G. static import utils.Repetition.twice;
Answer: ( F )
静态import引入静态方法和属性. import static utils..Repetition*; 或者 import static utils.Repetition.twice;
A 正常的导入类,Demo的第5行要new实例才能带用twice方法.
B static import 顺序颠倒,而且要加上class名
C 正常的导入,类名后面不能跟*
D 顺序颠倒
E 正常的导入,只能导入包下的类,不能导入类里的方法.
G 顺序颠倒
QUESTION 79
Given:
And the invocation:
What is the result?
A. An exception is thrown at runtime.
B. "String is empty" is printed to output.
C. Compilation fails because of an error in line 12.
D. "String is not empty" is printed to output.
Answer: ( A )
A空指针异常------------------“|”是非短路逻辑运算符
QUESTION 80
Exhibit:
Given the fully-qualified class names:
com.foo.bar.Dog
com.foo.bar.blatz.Book
com.bar.Car
com.bar.blatz.Sun
Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM?
A. Jar A
B. Jar B
C. Jar C
D. Jar D
E. Jar E
Answer: ( A )