欢迎来到易学考试网 易学考试官网
全部科目 > Java认证考试 > 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.

点击查看答案&解析

相关考题

微信小程序免费搜题
微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题