下列程序的运行结果是______。 public class Test { public static void main (String[] args) { int x=3, y=4, z=5; if (x>3) { if (y<2) System.out.print ("show one"); else System.out.print ("show two"); } else{ if (z>4) System.out.print ("show three"); else System.out.print ("show four"); } } }
A: show one
B: show two
C: show three
D: show four
A: show one
B: show two
C: show three
D: show four
举一反三
- 下列程序的运行结果? public class Test { public static void main(String a[]) { int x=3,y=4,z=5; if (x>3) { if (y<2) System.out.println("show one"); else System.out.println("show two"); } else { if (z>4) System.out.println("show three"); else System.out.println("show four"); } } }
- 定义类Block和类Demo,运行Demo的输出结果是。 class Block{ {//代码1 System.out.print("1"); } static{//代码2 System.out.print("2"); } {//代码3 System.out.print("3"); } public Block() {//代码4 System.out.print("4"); } static void show() {//代码5 System.out.print("5"); } static {//代码6 System.out.print("6"); } } //定义测试类Demo public class Demo { public static void main(String[] args) { new Block().show(); new Block() } }
- public class Example { public static void main(String[] args) { new Father () { public void show() { System.out.println("helloworld"); } }.show(); } } class Father { public void show() { System.out.println("hellofather"); } }
- 有如下类的定义。class A{ public void show() { show2(); } public void show2() { System.out.print("我"); }}class B extends A{ public void show2(){ System.out.print("爱"); }}class C extends B{ public void show() { super.show(); } public void show2() { System.out.print("你"); }}public class Test4 { public static void main(String[] args) { A a=new B(); a.show(); B b=new C(); b.show(); }} A: 我爱你 B: 爱你 C: 我爱 D: 我你
- 下面程序的运行结果是?public static void main(String[] args) { int x = 8; int y = 4; if(x++>8 && ++y<4){ System.out.print(x); }else{ System.out.print(y); } System.out.printf("%d%d",x,y);} A: 995 B: 985 C: 494 D: 495