Given:
1. public class Foo implements Runnable {
2. public void run (Thread t) {
3. System.out.println("Running.");
4. }
5. public static void main (String[] args) {
6. new Thread (new Foo()).start();
7. }
8. }
What is the result?
1. public class Foo implements Runnable {
2. public void run (Thread t) {
3. System.out.println("Running.");
4. }
5. public static void main (String[] args) {
6. new Thread (new Foo()).start();
7. }
8. }
What is the result?
举一反三
- class X implements Runnable{public static void main(String args[]){/* Missing code? */}public void run() {}}哪一行代码适合启动线程? A: Thread t = new Thread(X); B: Thread t = new Thread(X);t.start(); C: X run = new X();Thread t = new Thread(run);t.start(); D: Thread t = new Thread();x.run();
- 读代码: public class Test { public static void main (String args[]) { class Foo { public int i = 3; } Object o = (Object) new Foo(); Foo foo = (Foo)o; System.out.println(foo.i); } } 结果是:
- 读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是
- 以下程序的运行结果为: 1. public class Conditional { 2. public static void main(String args [] ) { 3. int x = 4; 4. System.out.println( "value is " + 5. ((x > 4) ? 99.99 : 9)); 6. } 7. }
- 智慧职教: 现有: 1. class Birds { 2. public static void main (String [] args) { 3. try { 4. throw new Exception () ; 5. } catch (Exception e) { 6. try { 7. throw new Exception () ; 8. } catch (Exceptio