SCJP真题库更新16

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 )

                                                         潮女时尚

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值