单选题11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?()A Line 13B Line 14C Line 18D Line 20
单选题
11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?()
A
Line 13
B
Line 14
C
Line 18
D
Line 20
参考解析
解析:
暂无解析
相关考题:
下列关于Test类的定义中,正确的是______。A) class Test implements Runnabte{public void run(){}public void someMethod(){}B) class Test implements Rnuuable{public void run();}C) class Test implements Rnuuable{public void someMethod();}D) class Test implements Rnuuable{public void someMethod();{}}A.B.C.D.
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?() A、 StackOverflowErrorB、 NullPointerExceptionC、 NumberFormatExceptionD、 IllegalArgumentExceptionE、 ExceptionlnlnitializerError
public class Test { public static void main(String [] args) { boolean assert = true; if(assert) { System.out.println(”assert is true”); } } } Given: javac -source 1.3 Test.java What is the result?() A、 Compilation fails.B、 Compilation succeeds with errors.C、 Compilation succeeds with warnings.D、 Compilation succeeds without warnings or errors.
11. public void addStrings(List list) { 12. list.add(”foo”); 13. list.add(”bar”); 14. } What must you change in this method to compile without warnings?() A、 add this code after line 11: list = (List) list;B、 change lines 12 and 13 to: list.add(”foo”); list.add(”bar”);C、 change the method signature on line 11 to: public void addStrings(List extends String list) {D、 change the method signature on line 11 to: public void addStrings(List super String list) {E、 No changes are necessary. This method compiles without warnings.
public class Test { public static void main (String args) { string foo = “blue”; string bar = foo; foo = “green”; System.out.printIn(bar); } } What is the result?() A、 An exception is thrown.B、 The code will not compile.C、 The program prints “null”D、 The program prints “blue”E、 The program prints “green”
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; }
11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?() A、 Line 13B、 Line 14C、 Line 18D、 Line 20
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 static void main( String[] argv ){ // insert statement here } } Which statement, inserted at line 3, produces the following output?() Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3) A、 assert true;B、 assert false;C、 assert false : true;D、 assert false == true;E、 assert false: false;
public class Test {} What is the prototype of the default constructor?() A、 Test()B、 Test(void)C、 public Test()D、 public Test(void)E、 public void Test()
10. interface Foo {} 11. class Alpha implements Foo {} 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?() A、 Alpha a = x;B、 Foo f= (Delta)x;C、 Foo f= (Alpha)x;D、 Beta b = (Beta)(Alpha)x;
public class Foo { public int a; public Foo() { a = 3; } public void addFive() { a += 5; } } and: public class Bar extends Foo { public int a; public Bar() { a = 8; } public void addFive() { this.a +=5; } } invoked with: Foo foo = new Bar(); foo.addFive(); System.out.println(”Value: “+ foo.a); What is the result?() A、 Value: 3B、 Value: 8C、 Value: 13D、 Compilation fails.E、 The code runs with no output.F、 An exception is thrown at runtime.
Given: 10. class One { 11. void foo() { } 12. } 13. class Two extends One { 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 public void foo() { /* more code here */ }B、 private void foo() { /* more code here */ }C、 protected void foo() { /* more code here */ }D、 int foo() { /* more code here */ } E、 void foo() { /* more code here */ }
单选题public class Foo { public int a; public Foo() { a = 3; } public void addFive() { a += 5; } } and: public class Bar extends Foo { public int a; public Bar() { a = 8; } public void addFive() { this.a +=5; } } invoked with: Foo foo = new Bar(); foo.addFive(); System.out.println(”Value: “+ foo.a); What is the result?()A Value: 3B Value: 8C Value: 13D Compilation fails.E The code runs with no output.F An exception is thrown at runtime.
多选题Given: 10. class One { 11. void foo() { } 12. } 13. class Two extends One { 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two?()Apublic void foo() { /* more code here */ }Bprivate void foo() { /* more code here */ }Cprotected void foo() { /* more code here */ }Dint foo() { /* more code here */ }Evoid foo() { /* more code here */ }
多选题10. interface Foo { 11. int bar(); 12. } 13. 14. public class Beta { 15. 16. class A implements Foo { 17. public int bar() { return 1; } 18. } 19. 20. public int fubar( Foo foo) { return foo.bar(); } 21. 22. public void testFoo() { 23. 24. class A implements Foo { 25. public int bar() { return 2; } 26. } 27. 28. System.out.println( fubar( new A())); 29. } 30. 31. public static void main( String[] argv) { 32. new Beta().testFoo(); 33. } 34. } Which three statements are true?()ACompilation fails.BThe code compiles and the output is 2.CIf lines 16, 17 and 18 were removed, compilation would fail.DIf lines 24, 25 and 26 were removed, compilation would fail.EIf lines 16, 17 and 18 were removed, the code would compile and the output would be 2.FIf lines 24, 25 and 26 were removed, the code would compile and the output would be 1.
单选题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 class Test { public static void main(String [] args) { boolean assert = true; if(assert) { System.out.println(”assert is true”); } } } Given: javac -source 1.3 Test.java What is the result?()A Compilation fails.B Compilation succeeds with errors.C Compilation succeeds with warnings.D Compilation succeeds without warnings or errors.
单选题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.
单选题10. interface Foo {} 11. class Alpha implements Foo {} 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?()A Alpha a = x;B Foo f= (Delta)x;C Foo f= (Alpha)x;D Beta b = (Beta)(Alpha)x;
多选题public class test { public static void main(String [] a) { assert a.length == 1; } } Which two will produce an AssertionError?()Ajava testBjava -ea testCjava test file1Djava -ea test file1Ejava -ea test file1 file2Fjava -ea:test test file1
单选题public class Test{ public static void main( String[] argv ){ // insert statement here } } Which statement, inserted at line 3, produces the following output?() Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)A assert true;B assert false;C assert false : true;D assert false == true;E assert false: false;
单选题10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()A StackOverflowErrorB NullPointerExceptionC NumberFormatExceptionD IllegalArgumentExceptionE ExceptionlnlnitializerError
单选题11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?()A Line 13B Line 14C Line 18D Line 20
填空题1. public class test { 2. public static string output = “” 3. 4. public static void foo(int i) { 5. try { 6. if(i= =1) { 7. throw new Exception (); 8. } 9. output += “1”; 10.} 11. catch(Exception e) { 12. output += “2”; 13. return; 14.} 15. finally ( 16. output += “3”; 17. ) 18. output += “4”; 19. } 20. 21. public static void main (string args[]) ( 22. foo(0); 23. foo(1); 24. 25. ) 26. } What is the value of the variable output at line 24?()
单选题public class Test {} What is the prototype of the default constructor?()A Test()B Test(void)C public Test()D public Test(void)E public void Test()