当前位置:SCJP程序员认证考试题库

问题:

[多选]

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.

以下教育机构中属于英国公立中学的有()。 文法中学。 技术中学。 综合中学。 公学。 初级学院。 简述中央秘书机构——太史寮的产生及影响。 家天下 德国的学位包括()。 文凭学位。 硕士学位。 博士学位。 学士学位。 教授备选资格。 在版编目

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?()

 

参考答案:

  参考解析

本题暂无解析

在线 客服