单选题Click the Exhibit button.   What is the result?()AThe code will deadlock.BThe code may run with output "2 0 6 4".CThe code may run with no output.DThe code may run with output "0 6".EAn exception is thrown at runtime.FThe code may run with output "0 2 

题目
单选题
Click the Exhibit button.   What is the result?()
A

 The code will deadlock.

B

 The code may run with output "2 0 6 4".

C

 The code may run with no output.

D

 The code may run with output "0 6".

E

 An exception is thrown at runtime.

F

 The code may run with output "0 2 4 6".


相似考题
更多“单选题Click the Exhibit button.   What is the result?()A  The code will deadlock.B  The code may run with output "2 0 6 4".C  The code may run with no output.D  The code may run with output "0 6".E  An exception is thrown at runtime.F  The code may run”相关问题
  • 第1题:

    public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes and prints “running”.
    • D、 The code executes and prints “runningrunning”.
    • E、 The code executes and prints “runningrunningrunning”.

    正确答案:E

  • 第2题:

    public class Transfers {  public static void main(String[] args) throws Exception {  Record r1 = new Record();  Record r2 = new Record();  doTransfer(r1, r2, 5);  doTransfer(r2, r1, 2);  doTransfer(r1, r2, 1);  // print the result  System.out.println(”rl = “ + r1.get() +“, r2=” + r2.get());  }  private static void doTransfer(  final Record a, final Record b, final int amount) {  Thread t = new Thread() {  public void run() {  new Clerk().transfer(a, b, amount);  }  };  t.start();  }  }  class Clerk {  public synchronized void transfer(Record a, Record b, int amount){  synchronized (a) {  synchronized (b) {  a.add(-amount);  b.add(amount);  }  }  }  }  class Record {  int num=10;  public int get() { return num; }  public void add(int n) { num = num + n; }  }  If Transfers.main() is run, which three are true?()

    • A、 The output may be “r1 = 6, r2 = 14”.
    • B、 The output may be “r1 = 5, r2 = 15”.
    • C、 The output may be “r1 = 8, r2 = 12”.
    • D、 The code may run (and complete) with no output.
    • E、 The code may deadlock (without completing) with no output.
    • F、 M IllegalStateException or InterruptedException may be thrown at runtime.

    正确答案:A,B,E

  • 第3题:

    What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }  

    • A、The code will fail to compile.
    • B、0 will be written to the standard output.
    • C、1 will be written to the standard output.
    • D、2 will be written to the standard output.
    • E、3 will be written to the standard output.

    正确答案:A

  • 第4题:

    public class TestOne implements Runnable {  public static void main (String[] args) throws Exception {  Thread t = new Thread(new TestOne());  t.start();  System.out.print(”Started”);  t.join();  System.out.print(”Complete”);  }  public void run() {  for (int i= 0; i< 4; i++) {   System.out.print(i);  }  }  }  What can be a result?()

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes and prints “StartedComplete”.
    • D、 The code executes and prints “StartedComplete0123”.
    • E、 The code executes and prints “Started0l23Complete”.

    正确答案:E

  • 第5题:

    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.

    正确答案:E,F

  • 第6题:

    Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work?   CODE BLOCK a:   Runnable r = new Runnable() {   public void run() {   Work.doIt();   }   };   Thread t = new Thread(r);   t.start();   CODE BLOCK b:   Thread t = new Thread() {  public void start() {   Work.doIt();  }  };   t.start();   CODE BLOCK c:   Runnable r = new Runnable() {   public void run() {   Work.doIt();   }   };   r.start();  CODE BLOCK d:   Thread t = new Thread(new Work());   t.start();   CODE BLOCK e:   Runnable t = new Runnable() {   public void run() {   Work.doIt();   }   };   t.run();  

    • A、Code block a.
    • B、Code block B.
    • C、Code block c.
    • D、Code block d.
    • E、Code block e.

    正确答案:A

  • 第7题:

    单选题
    public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes and prints “running”.

    D

     The code executes and prints “runningrunning”.

    E

     The code executes and prints “runningrunningrunning”.


    正确答案: D
    解析: 暂无解析

  • 第8题:

    多选题
    public class Transfers {  public static void main(String[] args) throws Exception {  Record r1 = new Record();  Record r2 = new Record();  doTransfer(r1, r2, 5);  doTransfer(r2, r1, 2);  doTransfer(r1, r2, 1);  // print the result  System.out.println(”rl = “ + r1.get() +“, r2=” + r2.get());  }  private static void doTransfer(  final Record a, final Record b, final int amount) {  Thread t = new Thread() {  public void run() {  new Clerk().transfer(a, b, amount);  }  };  t.start();  }  }  class Clerk {  public synchronized void transfer(Record a, Record b, int amount){  synchronized (a) {  synchronized (b) {  a.add(-amount);  b.add(amount);  }  }  }  }  class Record {  int num=10;  public int get() { return num; }  public void add(int n) { num = num + n; }  }  If Transfers.main() is run, which three are true?()
    A

    The output may be “r1 = 6, r2 = 14”.

    B

    The output may be “r1 = 5, r2 = 15”.

    C

    The output may be “r1 = 8, r2 = 12”.

    D

    The code may run (and complete) with no output.

    E

    The code may deadlock (without completing) with no output.

    F

    M IllegalStateException or InterruptedException may be thrown at runtime.


    正确答案: D,E
    解析: 暂无解析

  • 第9题:

    单选题
    Click the Exhibit button. Given: ClassA a = new ClassA( ); a.methodA( ); What is the result? ()
    A

    Compilation fails.

    B

    ClassC is displayed.

    C

    The code runs with no output.

    D

    An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第10题:

    单选题
    public class TestOne implements Runnable {  public static void main (String[] args) throws Exception {  Thread t = new Thread(new TestOne());  t.start();  System.out.print(”Started”);  t.join();  System.out.print(”Complete”);  }  public void run() {  for (int i= 0; i< 4; i++) {   System.out.print(i);  }  }  }  What can be a result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes and prints “StartedComplete”.

    D

     The code executes and prints “StartedComplete0123”.

    E

     The code executes and prints “Started0l23Complete”.


    正确答案: E
    解析: 暂无解析

  • 第11题:

    单选题
    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”.


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    You executed the following code:   BACKUP VALIDATE DATABASE;   BLOCKRECOVER CORRUPTION LIST;  What will be the result of executing the above code?()
    A

     The code will run a backup validation to populate the V$BACKUP_CORRUPTION view and repair corrupt blocks, if any, recorded in the view.

    B

     The code will run a backup validate to populate the V$COPY_CORRUPTION view and then repair any corrupt blocks recorded in the view.

    C

     The code will runs a backup validate to populate the V$DATABASE_BLOCK_CORRUPTION view and then repair corrupt blocks, if any, recorded in the view.

    D

     The code will run a backup validate to populate the RC_BACKUP_CORRUPTION view and then repair corrupt blocks, if any, recorded in the view.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes normally and prints “bar”.
    • D、 The code executes normally, but nothing prints.

    正确答案:C

  • 第14题:

    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()

    • A、 Hello
    • B、 Hello Foo
    • C、 Hello world
    • D、 Compilation fails.
    • E、 The code does not run.

    正确答案:E

  • 第15题:

    Runnable r = new Runnable() {  public void run() {  System.out.print(”Cat”);  }  };  Threadt=new Thread(r) {  public void run() {  System.out.print(”Dog”);  }  };  t.start();  What is the result?() 

    • A、 Cat
    • B、 Dog
    • C、 Compilation fails.
    • D、 The code runs with no output.
    • E、 An exception is thrown at runtime.

    正确答案:B

  • 第16题:

    public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()

    • A、 Finally
    • B、 Compilation fails.
    • C、 The code runs with no output.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第17题:

    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”.

    正确答案:F

  • 第18题:

    You executed the following code:   BACKUP VALIDATE DATABASE;   BLOCKRECOVER CORRUPTION LIST;  What will be the result of executing the above code?()  

    • A、 The code will run a backup validation to populate the V$BACKUP_CORRUPTION view and repair corrupt blocks, if any, recorded in the view.
    • B、 The code will run a backup validate to populate the V$COPY_CORRUPTION view and then repair any corrupt blocks recorded in the view.
    • C、 The code will runs a backup validate to populate the V$DATABASE_BLOCK_CORRUPTION view and then repair corrupt blocks, if any, recorded in the view.
    • D、 The code will run a backup validate to populate the RC_BACKUP_CORRUPTION view and then repair corrupt blocks, if any, recorded in the view.

    正确答案:C

  • 第19题:

    单选题
    Runnable r = new Runnable() {  public void run() {  System.out.print(”Cat”);  }  };  Threadt=new Thread(r) {  public void run() {  System.out.print(”Dog”);  }  };  t.start();  What is the result?()
    A

     Cat

    B

     Dog

    C

     Compilation fails.

    D

     The code runs with no output.

    E

     An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第20题:

    多选题
    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
    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.


    正确答案: D,E
    解析: 暂无解析

  • 第21题:

    单选题
    What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }
    A

    The code will fail to compile.

    B

    0 will be written to the standard output.

    C

    1 will be written to the standard output.

    D

    2 will be written to the standard output.

    E

    3 will be written to the standard output.


    正确答案: E
    解析: 暂无解析

  • 第22题:

    单选题
    Click the Exhibit button.   Given: ClassA a = new ClassA();   a.methodA();   What is the result?()
    A

     The code runs with no output.

    B

     Compilation fails.

    C

     An exception is thrown at runtime.

    D

     ClassC is displayed.


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()
    A

     Hello

    B

     Hello Foo

    C

     Hello world

    D

     Compilation fails.

    E

     The code does not run.


    正确答案: E
    解析: 暂无解析