移动端

  • 题王微信公众号

    微信搜“题王网”真题密题、最新资讯、考试攻略、轻松拿下考试

计算机考试 | Java认证考试

科目:

SCJP程序员认证考试

[切换]
考试
资讯

模式切换

0 0 0
我的错题 我的收藏 学习笔记

章节目录

多选题 import java.util.*;  public class NameList {  private List names = new ArrayList();  public synchronized void add(String name) { names.add(name); }  public synchronized void printAll() {  for (int i = 0; i System.out.print(names.get(i) +“ “); }  }  public static void main(String[] args) {  final NameList sl = new NameList();  for(int i=0;i<2;i++) {  new Thread() {  public void ruin() {  sl.add(”A”);  sl.add(”B”);  sl.add(”C”);  sl.printAll();  }  }.start();  }  }  }  Which two statements are true if this class is compiled and run?()

A

 An exception may be thrown at runtime.

B

 The code may run with no output, without exiting.

C

The code may rum with output “A B A B C C “, then exit.

D

The code may ruin with output “A A A B C A B C C “, then exit.

E

 The code may rum with output “A B C A B C A B C “, then exit.

F

The code may ruin with output “A B C A A B C A B C “, then exit.

单选题 Which statement is true?()

A

The equals method does NOT properly override the Object.equals method.

B

Compilation fails because the private attribute p.name cannot be accessed in line 5.

C

To work correctly with hash-based data structures, this class must also implement the hashCode method.

D

When adding Person objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates.

单选题 int index = 1;   boolean test = new Boolean;   boolean foo= test [index];  What is the result?()

A

 Foo has the value of 0.

B

 Foo has the value of null.

C

 Foo has the value of true.

D

 Foo has the value of false.

E

 An exception is thrown.

F

 The code will not compile.

单选题 What happens when thread X executes a wait() method on object A, without owning object A’s lock?()  

A

 Compilation fails.

B

 An exception is thrown.

C

 The wait() method has no effect.

D

 Thread X receives the lock immediately.

E

 Object A moves the thread to the wait pool.

1 2 3 4 5 下一页 尾页 /

到第