以下程序运行结果是?public class Test{int value;public static void main(String args[]) {Test t=new Test();if(t==null) {System.out.println("No Object");}else {System.out.println(t.value);}}}
A: 0
B:
C: NoObject
D: 编译错误
A: 0
B:
C: NoObject
D: 编译错误
举一反三
- 下列代码的执行结果是 。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 str = NULL;System.out.println(str);}} A:
- 有如下代码,则该程序运行时输出结果是。 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 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 Test { public static void main(String[] args) { String s1 = "abc"; String s2 = new String ("abc"); System.out.println(s1 == s2); } } 程序运行结果是