单选题interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()A Compilation succeeds.B An error at line 2 causes compilation to fail.C An error at line 9 causes compilation to fail.D An error at line 10 causes compilation to fail.E An error at line 11 causes compilation to fail.
单选题
interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()
A
Compilation succeeds.
B
An error at line 2 causes compilation to fail.
C
An error at line 9 causes compilation to fail.
D
An error at line 10 causes compilation to fail.
E
An error at line 11 causes compilation to fail.
参考解析
解析:
暂无解析
相关考题:
有如下类定义:class Foo{public:Foo(int v):value(v){} // ①~Foo(){} // ②private:Foo(){} // ③int value = 0; // ④};其中存在语法错误的行是A . ①B . ②C . ③D . ④
在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class
Given: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; }
下列代码中,将引起一个编译错误的行是( )。 1)public class Test{ 2) int m,n; 3) public Test(){} 4) public Test(int a){m=a;} 5) public static void main(String args[]){ 6) Test t1,t2; 7) int j,k; 8) j=0;k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12)}A.第3行B.第5行C.第6行D.第10行
在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }
有如下类定义: class Foo { public: Foo(int v) : value(v) { } // ① ~Foo() { } // ② private: Foo() { } // ③ int value = 0; // ④ }; 其中存在语法错误的行是( )。A.①B.②C.⑧D.④
下列代码中,将引起编译错误的行是______。 (1) public class Test { (2) int m,n; (3) public Test( ){} (4) public Test(int A){m=a;} (5) public static void main(String args[ ]){ (6) Test t1,t2; (7) int j,k; (8) j=0;k=0; (9) t1=new Test( ); (10) t2=new Test(j,k); (11) 1 (12) }A.第3行B.第5行C.第6行D.第10行
在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}
下列代码中,将引起一个编译错误的行是( )。 1)public class Test{ 2)int m,n; 3)public Test{} 4)public Test(int a){m=a;) 5)public static void main(String args[]){ 6)Test tl,t2; 7)int j,k; 8)j=0;k=0; 9)tl=new Test; 10)t2=new Test(j,k); 11)} 12)}A.第3行B.第5行C.第6行D.第l0行
在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }
以下程序的输出结果为:public class test {public static void main(String args[]) {int m=0;for ( int k=0;k A. 000B. 012C.123D.111
以下程序的输出结果为:public class test {public static void main(String args[]) {int s=0;for (int k=0;ks+=method(2,k)-1;System.out.println(s);}public static int method(int n,int m) {if (m==0)return 1;elsereturn n*method(n,m-1、;}}A. 2048B. 1024C. 2036D.2000
public interface Foo{ int k = 4; } Which three are equivalent to line 2?() A、 Final int k = 4;B、 Public int k = 4;C、 Static int k = 4;D、 Private int k = 4;E、 Abstract int k = 4;F、 Volatile int k = 4;
public interface Foo { int k = 4; 3. } Which three are equivalent to line 2?()A、 final int k = 4;B、 public int k = 4;C、 static int k = 4;D、 abstract int k = 4;E、 volatile int k = 4;F、 protected int k = 4;
class One { public One foo() { return this; } } class Two extends One { public One foo() { return this; } } class Three extends Two { // insert method here } 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; }
Given: 1. public interface Foo { 2. int k = 4: 3. } Which three are equivalent to line 2?()A、 final int k = 4:B、 public int k = 4:C、 static int k = 4:D、 private int k = 4:E、 abstract int k = 4:F、 volatile int k = 4:G、 transient int k = 4:H、 protected int k = 4:
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(“i = “ + foo.i); } } What is the result?() A、 i = 3B、 Compilation fails.C、 A ClassCastException is thrown at line 6.D、 A ClassCastException is thrown at line 7.
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
public interface Foo{ int k = 4; } Which three are equivalent to line 2? ()A、 Final int k = 4;B、 Public int k = 4;C、 Static int k = 4;D、 Private int k = 4;E、 Abstract int k = 4;F、 Volatile int k = 4;G、 Transient int k = 4;H、 Protected int k = 4;
interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()A、 Compilation succeeds.B、 An error at line 2 causes compilation to fail.C、 An error at line 9 causes compilation to fail.D、 An error at line 10 causes compilation to fail.E、 An error at line 11 causes compilation to fail.
多选题public interface Foo { int k = 4; 3. } Which three are equivalent to line 2?()Afinal int k = 4;Bpublic int k = 4;Cstatic int k = 4;Dabstract int k = 4;Evolatile int k = 4;Fprotected int k = 4;
单选题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.printIn(foo. i); } } What is the result?()A Compilation will fail.B Compilation will succeed and the program will print “3”C Compilation will succeed but the program will throw a ClassCastException at line 6.D Compilation will succeed but the program will throw a ClassCastException at line 7.
单选题10. interface Foo { int bar(); } 11. public class Sprite { 12. public int fubar( Foo foo) { return foo.bar(); } 13. public void testFoo() { 14. fubar( 15. // insert code here 16.); 17. } 18. } 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 newFoo() { public int bar(){return 1; } }D new class Foo { public int bar() { return 1; } }
单选题1. interface foo { 2. int k = 0; 3. } 4. 5. public class test implements Foo ( 6. public static void main(String args[]) ( 7. int i; 8. Test test = new test (); 9. i= test.k; 10.i= Test.k; 11.i= Foo.k; 12.) 13.) 14. What is the result?()A Compilation succeeds.B An error at line 2 causes compilation to fail.C An error at line 9 causes compilation to fail.D An error at line 10 causes compilation to fail.E An error at line 11 causes compilation to fail.
多选题public interface Foo{ int k = 4; } Which three are equivalent to line 2? ()AFinal int k = 4;BPublic int k = 4;CStatic int k = 4;DPrivate int k = 4;EAbstract int k = 4;FVolatile int k = 4;GTransient int k = 4;HProtected int k = 4;
多选题public interface Foo{ int k = 4; } Which three are equivalent to line 2?()AFinal int k = 4;BPublic int k = 4;CStatic int k = 4;DPrivate int k = 4;EAbstract int k = 4;FVolatile int k = 4;
单选题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(“i = “ + foo.i); } } What is the result?()A i = 3B Compilation fails.C A ClassCastException is thrown at line 6.D A ClassCastException is thrown at line 7.