[单选题]

class Computation extends Thread { 

private int num; 

private boolean isComplete; 

private int result; 

public Computation(int num) { this.num = num; } 

public synchronized void run() { 

result = num * 2; 

isComplete = true; 

notify(); 

} 

public synchronized int getResult() { 

while (!isComplete) { 

try { 

wait(); 

} catch (InterruptedException e) { } 

} 

return result; 

} 

public static void main(String[] args) { 

Computation[] computations = new Computation [4]; 

for (int i = 0; i < computations.length; i++) { 

computations[i] = new Computation(i); 

computations[i] .start(); 

} 

for (Computation c : computations) 

System.out.print(c.getResult() +“ “); 

} 

} 

What is the result?() 

A .  The code will deadlock.

B .  The code may run with no output.

C .  An exception is thrown at runtime.

D .  The code may run with output “0 6”.

E .  The code may run with output “2 0 6 4‟.

F .  The code may ruin with output “0 2 4 6”.

参考答案与解析:

相关试题

You are the network 

[单选题]You are the network administrator for Contoso, Ltd. The network consists of a single Active Directory forest that contains a single domain n

  • 查看答案
  • You are managing an 

    [多选题] You are managing an Oracle Database 11g database with ASM storage. The ASM disk group has the COMPATIBLE.ASM attribute set to 11.1. Which&e

  • 查看答案
  • View the Exhibit and&ensp

    [单选题]View the Exhibit and examine the properties of the TT tablespace. Using Database Control, you have scheduled a job to shrink the TRANS 

  • 查看答案
  • You need to create a

    [单选题]You need to create a web share on your Windows 2000 Professional computer named Admin01. You create a folder named reports. Then you co

  • 查看答案
  • Your company has an 

    [单选题]Your company has an Active Directory domain. A server named Server1 runs Windows Server 2008. The Terminal Services role and the Terminal Se

  • 查看答案
  • You work as the ente

    [单选题]You work as the enterprise exchange administrator at TestKing.com. TestKing.com makes use ofMicrosoft Exchange Server messaging solution. The TestKing.com 

  • 查看答案
  • You are the DNS admi

    [单选题]You are the DNS administrator for Adventure Works. Adventure Works is an Internet service provider (ISP) that hosts Web sites for many compa

  • 查看答案
  • You work in a compan

    [单选题]You work in a company which is named Wiikigo Corp. The company uses SQL Server 2008. You are the administrator of the company database.

  • 查看答案
  • You have a server th

    [单选题]You have a server that runs Windows Server 2008. The server has the Windows Server virtualization roleservice installed and has one virtual 

  • 查看答案
  • 现有:  public interface&ens

    [单选题]现有:  public interface A {}  以下哪项声明是合法的?() A . a = new A();B .  A[] a = new A[];C .  A[] a = new A[10];D .  以上皆错

  • 查看答案
  • class Computation extends&ensp