以下程序编译和运行会发生什么public class Q8 {int i =...ut.println(a.i);}}
举一反三
- 以下程序编译和运行会发生什么public class Q8 {int i = 20;static { int i = 10; }public static void main(String[] args) {Q8 a = new Q8();System.out.println(a.i);}}
- 当你编译运行下列程序代码,会得到什么结果? 。 private class Base{ Base(){ int i = 100; System.out.println(i); } } public class Pri extends Base{ static int i = 200; public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }
- 给定Java代码如下,编译运行,结果是public class Test{ public static void main(String[] args){ int i; int j=0; int k=2; System.out.println(”i=”+i); } } A: 编译错误 B: 运行时出现异常 C: 正常运行,输出i=-1 D: 正常运行,输出i=0
- 分析程序,将代码补充完整class A { private int x; public A(int i) { x = i; } } class B extends A { private int y; public B(int i) { ___________ ____; y = i; } }
- 下面程序段的输出结果是( )。 public class Test public static void main ( String[] args) int result=0; for ( int i=1;i<=5;i++) if ( i%2==0 ) continue; result + =i; System. out. println ("result is " + result ); A: result is 7 B: result is 8 C: result is 9 D: result is 10