阅读以下程序class A{public A(int n){Console.Write(“A”);}public A(string s,int n):this(0){Console.Write(“C”);}}class B:A{public B(int n):base(0){Console.Write(“B”);}}class Test{static void Main(){B b = new B(1);}}以上程序运行后的输出结果是()
A: BC
B: AB
C: BA
D: CB
A: BC
B: AB
C: BA
D: CB
举一反三
- 写出以下程序运行结果。const int N=5; public static void Main (){ int a = 0; for(int i=1; i<;N; i++) { int c=0, b=2; a+=3; c=a+b; Console.write (c + “ ” ); }程序运行后输出结果为:____
- 下列代码输出为( ): class Father{ public void F() { Console.Write("A.F"); } public virtual void G() { Console.Write("A.G"); } } class Son: Father{ new public void F() { Console.Write("B.F"); } public override void G() { Console.Write("B.G"); } } class override_new{ static void Main() { Son b = new Son(); Father a = b; a.F(); b.F(); a.G(); b.G(); } }
- 以下程序运行结果为: public class Q { public static void main(String argv[]) { int anar[]= new int[5]; System.out.println(anar[0]); } }
- 有如下代码,则该程序运行时输出结果是。 class Test{ static int i=0; public void show() { i++; System.out.println(i); } } public class Demo { public static void main(String[] args) { Test test=new Test(); test.show(); } }
- 以下程序运行结果是 public class Test { public static void main(String[] args) { int a=1,b[]={2}; add(a); add(b); System.out.println(a+","+b[0]); } static int add(int x){ x++; return x; } static void add(int[] x){ x[0]++; } }