编译并运行下面的程序,结果是
public class A {
public static void main(String args[]) {
B b = new B();
b.test();
}
void test() {
System.out.print("A");
}
}
class B extends A {
void test() {
super.test();
System.out.println("B");
}
}
public class A {
public static void main(String args[]) {
B b = new B();
b.test();
}
void test() {
System.out.print("A");
}
}
class B extends A {
void test() {
super.test();
System.out.println("B");
}
}
举一反三
- 有如下代码,则该程序运行时输出结果是。 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(); } }
- 请阅读下面的程序 class Test { private static String name; static { name = "World"; System.out.print (name); } public static void main(String[] args) { System.out.print("Hello"); Test test = new Test(); } } 下列选项中,程序运行结果是
- 下列代码的执行结果是 。public class Test {public int aMethod(){static int i=0;i++;System.out.println(i);}public static void main(String args[ ]){Test test = new Test();test.aMethod();}}
- public class Test { public static void main(String[] args) { String s1 = "abc"; String s2 = new String ("abc"); System.out.println(s1 == s2); } } 程序运行结果是
- 下列程序的运行结果是()public class Test {public static void main(String[] args) {String str = NULL;System.out.println(str);}} A: