题目内容

程序的输出结果为:()。class A{final public int GetResult(int a, int b) { return 0; }} class B extends A{public int GetResult(int a, int b) {return 1; }} public class Test{public static void main(String args[]){B b = new B();System.out.println("x = " + b.GetResult(0, 1));}}

A. x = 0
B. x = 1
C. 编译错误
D. 运行时异常

查看答案
更多问题

以下程序的输出结果为:()class SC2{public static void main(String [] args){SC2 s = new SC2();s.start();}void start(){int a = 3;int b = 4;System.out.print(" " + 7 + 2 + " ");System.out.print(a + b);System.out.print(" " + a + b + " ");System.out.print(foo() + a + b + " ");System.out.println(a + b + foo());}String foo(){return "foo";}}

A. 9 7 7 foo 7 7foo
B. 72 34 34 foo34 34foo
C. 9 7 7 foo34 34foo
D. 72 7 34 foo34 7foo

以下程序的输出结果为:()class BoolArray{boolean [] b = new boolean[3];int count = 0;void set(boolean [] x, int i){x[i] = true;++count;}public static void main(String [] args){BoolArray ba = new BoolArray();ba.set(ba.b, 0);ba.set(ba.b, 2);ba.test();}void test(){if ( b[0] && b[1] | b[2] )count++;if ( b[1] && b[(++count - 2)] )count += 7;System.out.println("count = " + count);}}

A. count = 0
B. count = 2
C. count = 3
D. count = 4

public void foo( boolean a, boolean b){if( a ){System.out.println("A"); /* Line 5 */}else if(a && b) /* Line 7 */{System.out.println( "A && B");}else /* Line 11 */{if ( !b ){System.out.println( "notB") ;}else{System.out.println( "ELSE" ) ;}}}

A. If a is true and b is true then 输出 "A && B"
B. If a is true and b is false then 输出 "notB"
C. If a is false and b is true then 输出 "ELSE"
D. If a is false and b is false then 输出 "ELSE"

以下程序的输出结果为:()public class Test{public static void aMethod() throws Exception{try/* Line 5 */{throw new Exception();/* Line 7 */}finally/* Line 9 */{System.out.print("finally ");/* Line 11 */}}public static void main(String args[]){try{aMethod();}catch (Exception e) /* Line 20 */{System.out.print("exception ");}System.out.print("finished");/* Line 24 */}}

A. finally
B. exception finished
C. finally exception finished
D. Compilation fails

答案查题题库