求学资讯 JAVA培训 提问
JAVA培训 > 历年真题

JAVA认证SCJP认证真题及答案(15)

来源:用户上传 上传用户:zhongzhanen 发布时间:2017-12-28

导读:
想要第一时间获得JAVA考试报考信息,想要充分利用各种精华资讯资源备考,想要海量高质量、高含金量的习题练习,关注“求学快递网”公众号,你不能错过的考试利器!

  QUESTION NO 131

  Exhibit:

  1. public class SwitchTest {

  2. public static void main (String args) {

  3. System.out.PrintIn(“value =” +switchIt(4));

  4. }

  5. public static int switchIt(int x) {

  6. int j = 1;

  7. switch (x) {

  8. case 1: j++;

  9. case 2: j++;

  10. case 3: j++;

  11. case 4: j++; 

  12. case 5: j++;

  13. default:j++;

  14. }

  15. return j + x;

  16. }

  17. }

  What is the output from line 3?

  A. Value = 3

  B. Value = 4

  C. Value = 5

  D. Value = 6

  E. Value = 7

  F. Value = 8

  Answer: F

  QUESTION NO 132

  Which four types of objects can be thrown using the throw statement? (Choose Four)

  A. Error

  B. Event

  C. Object

  D. Exception

  E. Throwable

  F. RuntimeException

  Answer: A, D, E, F

  QUESTION NO 133

  Given:

  1. public class ForBar {

  2. public static void main(String args) { 中华考试网(www.Examw。com)

  3. int i = 0, j = 5;

  4. tp: for (;;) {

  5. i ++;

  6. for(;;)

  7. if(i > --j) break tp;

  8. }

  9. system.out.printIn(“i = ” + i + “, j = “+ j);

  10. }

  11. }

  What is the result?

  A. The program runs and prints “i=1, j=0”

  B. The program runs and prints “i=1, j=4”

  C. The program runs and prints “i=3, j=4”

  D. The program runs and prints “i=3, j=0”

  E. An error at line 4 causes compilation to fail.

  F. An error at line 7 causes compilation to fail.

  Answer: A

  QUESTION NO 134

  Which two can directly cause a thread to stop executing? (Choose Two)

  A. Exiting from a synchronized block.

  B. Calling the wait method on an object.

  C. Calling the notify method on an object.

  D. Calling the notifyAll method on an object.

  E. Calling the setPriority method on a thread object.

  Answer: B, E

  QUESTION NO 135

  Given:

  1. public class Foo implements Runnable (

  2. public void run (Thread t) {

  3. system.out.printIn(“Running.”);

  4. }

  5. public static void main (String args) {

  6. new thread (new Foo()).start();

  7. )

  8. )

  What is the result?

  A. An exception is thrown.

  B. The program exists without printing anything.

  C. An error at line 1 causes compilation to fail.

  D. An error at line 6 causes the compilation to fail.

  E. “Running” is printed and the program exits.

  Answer: C

声明:本站为免费网络服务提供商,网站所有信息均为用户自行发布并由用户承担相应法律责任,本站不对其真实性及合法性负责,如涉及侵权或者信息违法,请你及时与本站联系删除。

阅读 1122 举报

相关推荐
评论0

当前没有评论内容

发表评论 0条评论
64
微博
QQ
QQ空间
微信
取消