public class Threads4 {  public static void main (String[] args) {  new Threads4().go();  }  public void go() {  Runnable r = new Runnable() { public void run() {  System.out.print(”foo”);  }  };  Thread t = new Thread(r);  t.start();  t.start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.

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

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

相关考题:

Given that a scoped attribute cart exists only in a user’s session, which two,taken independently,ensurethe scoped attribute cart no longer exists?()A、${cart = null}B、c:remove var="cart" /C、c:remove var="${cart}" /D、c:remove var="cart" scope="session" /E、c:remove scope="session"cart/c:remove

假设在目录myprj/src/school中有Java源文件Student.java,如果希望该文件编译后的类文件出现在目录myprj/classes/school中,应该使用下列哪一个命令?() A、cd myprj/src javac –d ../classes school/Student.javaB、cd myprj/src javac ../classes school/*.javaC、cd myprj javac –d ../classes school/*.javaD、cd myprj/src/school javac –d ../classes school/Student.java

为了良好地组织包结构,Java系统会自动分析包名,并将包名分解为一级级的子目录名,再进行编译或执行。

What will be written to the standard output when the following program is run?()   public class Q03e4 {   public static void main(String args[]) {   String space = " ";   String composite = space + "hello" + space + space;   composite.concat("world");   String trimmed = composite.trim();   System.out.println(trimmed.length());   }   }  A、5B、6C、7D、12E、13

public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  A、 Throws Exception.B、 Catch (Exception e).C、 Throws RuntimeException.D、 Catch (TestException e).E、 No code is necessary.

工具栏是图形界面程序常用的组件。它将一组控件(以按钮为主)排 成一行中,放在程序的顶端。

public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i4;i++){  current = x;  System.out.print(current + “, “);  x = current + 2;  }  }  }  public static void main(String[] args) {  new Threads1().go();  }  public void go() {  Runnable r1 = new Runner();  new Thread(r1).start();  new Thread(r1 ).start();  }  }  Which two are possible results?()A、 0, 2, 4, 4, 6, 8, 10, 6,B、 0, 2, 4, 6, 8, 10, 2, 4,C、 0, 2, 4, 6, 8, 10, 12, 14,D、 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,E、 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,

对于变量的初始化,以下几种方法中错误的是() A、int a; for (int i=0;i《12;i++)       a=i;B、int a; if (true)         a=7;C、int a;  int b=a;D、int a=0;E、int a;   a=0;

import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()  A、 The code will not compile.B、 The output is caught exception.C、 The output is caught IOException.D、 The program executes normally without printing a message.

下面哪些布局管理影响容器内控件的大小()A、GridLayoutB、BorderLayoutC、FlowLayoutD、GridBagLayout

What will be written to the standard output when the following program is run?()   public class Qcb90 {   int a;   int b;   public void f() {  a = 0;   b = 0;   int[] c = { 0 };   g(b, c);   System.out.println(a + " " + b + " " + c[0] + " ");   }   public void g(int b, int[] c) {   a = 1;  b = 1;  c[0] = 1;  }   public static void main(String args[]) {   Qcb90 obj = new Qcb90();   obj.f();   }   }  A、0 0 0B、0 0 1C、0 1 0D、1 0 0E、1 0 1