assert true;
assert false;
assert false : true;
assert false == true;
assert false: false;
第1题:
Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?() class A {} class B extends A {} class C extends A {} public class Q3ae4 { public static void main(String args[]) { A x = new A(); B y = new B(); C z = new C(); // insert statement here } }
第2题:
public class Test { public static void main (String[]args) { String foo = args[1]; String bar = args[2]; String baz = args[3]; System.out.printIn(“baz = ” + baz); } } And the output: Baz = 2 Which command line invocation will produce the output?()
第3题:
1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? ()
第4题:
Given the following code: public class Person{ static int arr[] = new int[10]; public static void main(String a[]) { System.out.println(arr[1];) } } Which statement is correct?()
第5题:
Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object. class Base { public void print( ) { System.out.println("base"); } } class Extention extends Base { public void print( ) { System.out.println("extension"); // insert line of implementation here } } public class Q294d { public static void main(String args[]) { Extention ext = new Extention( ); ext.print( ); } } Fill in a single line of implementation.()
第6题:
on line 2
on line 3
on line 6
on line 7
第7题:
InsideOnew ei= eo.new InsideOn();
Eo.InsideOne ei = eo.new InsideOne();
InsideOne ei = EnclosingOne.new InsideOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
第8题:
When compilation some error will occur.
It is correct when compilation but will cause error when running.
The output is zero.
The output is null.
第9题:
Compilation succeeds and d takes the value 253.
Line 5 contains an error that prevents compilation.
Line 5 throws an exception indicating “Out of range”
Line 3 and 4 contain error that prevent compilation.
The compilation succeeds and d takes the value of 1.
第10题:
assert true;
assert false;
assert false : true;
assert false == true;
assert false: false;
第11题:
NULL
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第12题:
第13题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()
第14题:
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)
第15题:
public class X { public static void main (String[] args) { byte b = 127; byte c = 126; byte d = b + c; } } Which statement is true?()
第16题:
1. public class enclosingone ( 2. public class insideone{} 3. ) 4. public class inertest( 5. public static void main (string[]args)( 6. enclosingone eo= new enclosingone (); 7. //insert code here 8. ) 9. ) Which statement at line 7 constructs an instance of the inner class?()
第17题:
Consider the following class: class Test(int i) { void test(int i) { System.out.println(“I am an int.”); } void test(String s) { System.out.println(“I am a string.”); } public static void main(String args) { Test t=new Test(); char ch=“y”; t.test(ch); } } Which of the statements below is true?()
第18题:
public void main(String args[])
public void static main(String args[])
public static main(String[] argv)
final public static void main(String [] array)
public static void main(String args[])
第19题:
c = b;
c = this.a;
c = this.b;
c = Q4a39.this.a;
c = c;
第20题:
on line 2
on line 3
on line 6
on line 7
第21题:
Java Test 2222
Java Test 1 2 3 4
Java Test 4 2 4 2
Java Test 4 3 2 1
第22题:
Java Test 2222
Java Test 1 2 3 4
Java Test 4 2 4 2
Java Test 4 3 2 1
第23题:
Line 5 will not compile, because void methods cannot be overridden.
Line 12 will not compile, because there is no version of test() that rakes a charargument.
The code will compile but will throw an exception at line 12.
The code will compile and produce the following output: I am an int.
The code will compile and produce the following output: I am a String.
第24题:
x = y;
z = x;
y = (B) x;
z = (C) y;
y = (A) y;