| ACCA | CET | EMBA | GMAT | GRE | JAVA认证 | Linux认证 | LSAT | MBA | MPA | Oracle认证 | PETS | TOEIC | 保险资格 | 报关员 | 报检员 | 成人高考 | 城市规划师 | 大学英语 | 导游 | 电子商务师 | 法律硕士 | 房产估价师 | 高级会计师 | 工程硕士 | 公务员 | 国际内审师 | 国际商务师 | 会计硕士 | 会计职称 | 会计资格 | 计算机等级考试 | 监理工程师 | 建造师 | 建筑师 | 结构工程师 | 经济师 | 精算师 | 考试试题 | 考研 | 口译笔译 | 秘书认证 | 人力资源师 | 软件水平考试 | 商务英语 | 实用英语 | 司法考试 | 思科认证 | 同等学历 | 土地估价师 | 托福考试 | 外销员 | 微软认证 | 物流师 | 项目管理师 | 小语种 | 雅思考试 | 在职硕士 | 造价师 | 证券认证 | 执业护士 | 执业药师 | 执业医师 | 职称英语 | 注册会计师 | 注册税务师 | 咨询工程师 | 资产评估师 | 自学考试 |
华夏学习网_JAVA认证_JAVA认证题库_ SCJP考试真题和解析[1]

SCJP考试真题和解析[1]

Choose the three valid identifiers from those listed below.

  A. IDoLikeTheLongNameClass

  B. $byte

  C. const

  D. _ok

  E. 3_case

  解答:A, B, D

  点评:中的标示符必须是字母、美元符($)或下划线(_)开头。关键字与保留字不能作为标示符。选项C中的const是Java的保留字,所以不能作标示符。选项E中的3_case以数字开头,违反了Java的规则。

  例题2:

  How can you force garbage collection of an object?

  A. Garbage collection cannot be forced

  B. Call System.gc().

  C. Call System.gc(), passing in a reference to the object to be garbage collected.

  D. Call Runtime.gc().

  E. Set all references to the object to new values(null, for example).

  解答:A

  点评:在Java中垃圾收集是不能被强迫立即执行的。调用System.gc()或Runtime.gc()静态方法不能保证垃圾收集器的立即执行,因为,也许存在着更高优先级的线程。所以选项B、D不正确。选项C的错误在于,System.gc()方法是不接受参数的。选项E中的方法可以使对象在下次垃圾收集器运行时被收集。

 


 例题3:
 Consider the following class:

  1. class Test(int i) {

  2. void test(int i) {

  3. System.out.println(“I am an int.”);

  4. }

  5. void test(String s) {

  6. System.out.println(“I am a string.”);

  7. }
  
  8.
  
  9. public static void main(String args[]) {

  10. Test t=new Test();

  11. char ch=“y”;

  12. t.test(ch);

  13. }

  14. }

  Which of the statements below is true?(Choose one.)

  A. Line 5 will not compile, because void methods cannot be overridden.

  B. Line 12 will not compile, because there is no version of test() that rakes a char argument.

  C. The code will compile but will throw an exception at line 12.

  D. The code will compile and produce the following output: I am an int.

  E. The code will compile and produce the following output: I am a String.

  解答:D

  点评:在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。

  例题4:

  Which of the following lines of code will compile without error?

  A.
  int i=0;
  if (i) {
  System.out.println(“Hi”);
  }

  B.
  boolean b=true;
  boolean b2=true;
  if(b==b2) {
  System.out.println(“So true”);
  }

  C.
  int i=1;
  int j=2;
  if(i==1|| j==2)
  System.out.println(“OK”);

  D.
  int i=1;
  int j=2;
  if (i==1 &| j==2)
  System.out.println(“OK”);

  解答:B, C

  点评:选项A错,因为if语句后需要一个boolean类型的表达式。逻辑操作有^、&、| 和 &&、||,但是“&|”是非法的,所以选项D不正确。

  例题5:

  Which two demonstrate a "has a" relationship? (Choose two)

  A. public interface Person { }

文章发布:华夏学习网 发布时间:2006-07-16
版权所有©2004-2008 华夏学习网 edu114.cn. 保留所有权利  ICP许可证编号:京06063949号