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: 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;}}
举一反三
- 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;}
- 关于下列代码说法正确的是( ) 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)); } }
- int index = 1; int foo = new int ; int bar = foo [index]; int baz = bar + index; What is the result?() A: Baz has the value of 0 B: Baz has the value of 1 C: Baz has the value of 2 D: An exception is thrown. E: The code will not compile.
- 读代码: 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); } } 结果是:
- int index = 1; int [] foo = new int [3]; int bar = foo [index]; int baz = bar + index; What is the result?() A: Baz has the value of 0 B: Baz has the value of 1 C: Baz has the value of 2 D: An exception is thrown. E: The code will not compile.