Which two methods, inserted individually, correctly complete the Three class?()
A: public void foo(){ }
B: public int foo(){return 3;}
C: public Two foo(){return this;}
D: public One foo(){return this;}
E: public Object foo(){return this;}
A: public void foo(){ }
B: public int foo(){return 3;}
C: public Two foo(){return this;}
D: public One foo(){return this;}
E: public Object foo(){return this;}
举一反三
- Which code, inserted at line 15, allows the class Sprite to compile?() A: Foo{public int bar(){return 1;}} B: new Foo{public int bar(){return 1;}} C: new Foo(){public int bar(){return 1;}} D: new class Foo{public int bar(){return 1;}}
- 下列代码中正确的是( )。(选择两项) A: public String foo() { return “我爱中国”; } B: public void foo(){<br> return ”-我爱中国”; } C: public String foo(){<br> String s=”我爱中国”; return s; } D: public int foo(){<br> String s=“我爱中国”; return s; }
- 读代码: 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{ public int add(int a,int b){ return a+b; } public static void main(String[] args){ Foo foo = null; System.out.println(foo.add(10,20)); } }
- 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?