网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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 with output "0 2 4 6".” 相关考题
考题 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 compileB.this code compliles but throws an exception at runtimeC.this code runs and “constructor” in the standard outputD.this code runs and writes “null” in the standard output

考题 Click the Exhibit button. What is the result? () A.Value is: 8B.Compilation fails.C.Value is: 12D.Value is: -12E.The code runs with no output.F.An exception is thrown at runtime.

考题 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.

考题 Click the Exhibit button. What is the output if the main() method is run?() A.4B.5C.8D.9E.Compilation fails.F.An exception is thrown at runtime.G.It is impossible to determine for certain.

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

考题 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.

考题 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.

考题 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、 HelloB、 Hello FooC、 Hello worldD、 Compilation fails.E、 The code does not run.

考题 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.

考题 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、 CatB、 DogC、 Compilation fails.D、 The code runs with no output.E、 An exception is thrown at runtime.

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

考题 public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()A、 FinallyB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

考题 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;i2;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.

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

考题 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.

考题 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.

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

考题 单选题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  CatB  DogC  Compilation fails.D  The code runs with no output.E  An exception is thrown at runtime.

考题 多选题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?()AThe output may be “r1 = 6, r2 = 14”.BThe output may be “r1 = 5, r2 = 15”.CThe output may be “r1 = 8, r2 = 12”.DThe code may run (and complete) with no output.EThe code may deadlock (without completing) with no output.FM IllegalStateException or InterruptedException may be thrown at runtime.

考题 多选题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;iAAn exception may be thrown at runtime.BThe code may run with no output, without exiting.CThe code may rum with output “A B A B C C “, then exit.DThe code may ruin with output “A A A B C A B C C “, then exit.EThe code may rum with output “A B C A B C A B C “, then exit.FThe code may ruin with output “A B C A A B C A B C “, then exit.

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

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

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

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

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

考题 单选题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  HelloB  Hello FooC  Hello worldD  Compilation fails.E  The code does not run.

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