1Z0-853

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

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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.


参考答案:D

第2题:

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

第3题:

What happens when you try to compile and run the following program?

class Mystery{String s;public static void main(String[] args){

Mystery m=new Mystery();m.go();}void Mystery(){s=”constructor”;}void go(){System.out.println(s);}

}()

A.this code will not compile

B.this code compliles but throws an exception at runtime

C.this code runs and “constructor” in the standard output

D.this code runs and writes “null” in the standard output


参考答案:D

第4题:

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

第5题:

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

第6题:

Click the Exhibit button. What is the output if the main() method is run?()

A.4

B.5

C.8

D.9

E.Compilation fails.

F.An exception is thrown at runtime.

G.It is impossible to determine for certain.


参考答案:D

第7题:

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

第8题:

Click the Exhibit button. What is the result? ()

A.Value is: 8

B.Compilation fails.

C.Value is: 12

D.Value is: -12

E.The code runs with no output.

F.An exception is thrown at runtime.


参考答案:A

第9题:

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

第10题:

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

更多相关问题