现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()     A、1B、2C、3D、编译失败

现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()     

  • A、1
  • B、2
  • C、3
  • D、编译失败

相关考题:

下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3

执行下列代码后,输出的结果为( )。 class Base { int x = 30; void setX( ) {x=1O;} } class SubClass extends Base { int x=40; void setX ( ) {x=20;} int getX( ) {return super. x; } } public class Test { public static void main(String[ ] args) { SubClass sub=new SubClass( ); sub. setX( ); System. out. println(sub, getX( ) ); } }A.10B.20C.30D.40

请将下面程序补充完整。public class PowerCalc{public static void main(String[]args){double x=5.0;System. out. println(x+"to the power 4 is"+power(x, 4));System. out. println("7. 5 to the power 5 is"+power(7.5, 5));System. out. println("7.5 to the power 0 is"+power(7.5, 0));System. out. println("10 to the power -2 is"+power(10, -2));}static double【 】 (double x, int n){if(n>1)return x * power(x, n-1);else if(n<0)return 1.0/power(x, -n);elsereturn n==0 ? 1.0:x;}}

interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}

执行下列代码段之后,x的值为______。 public class ex25 { public static void main(String[] args) { int x=12; int m=x%5; x>>>=m; System.out.println(x); }A.7B.3C.0D.1

下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过

执行如下语句之后,输出的结果是______。 public class ex24 { public static void main(String[] args) { int x=5,y=3; x+=X-- *--y; System.out.println{x); } }A.0B.1C.trueD.false

以下程序的运行结果为:public class A {static int k=3;public static void main(String[] args) {int k=4;A x1=new A();x1.k++;A x2=new A();x2.k++;k++;System.out.println(x1.k);}} A. 3B. 4C.5D.6E.7

设有如下类class Loop{public static void main(String[] agrs) {int x=0;int y=0;outer:for(x=0;xmiddle:for(y=0;ySystem.out.println("x="+x+"; y="+y);if(y==10){>}}}}}在>处插入什么代码可以结束外循环?A.continue middle;B.break outer;C.break middle;D.continue outer;E.none of these

以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误

现有:  class Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()     A、55B、56C、65D、66

现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()    A、  2B、  3C、  4D、编译失败

class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() A、 TestAB、 TestBC、 Compilation fails.D、 An exception is thrown at runtime.

class Top {  static int x = 1;  public Top(int y) { x *= 3; }  }  class Middle extends Top {  public Middle() { x += 1; }  public static void main(String [] args) {  Middle m = new Middle();  System.out.println(x);  }  }  结果为:() A、1B、2C、3D、编译失败

现有:      class TestA  {  public void start()  {  System.out.println("TestA");  }     }  public class TestB extends TestA  {  public void start()  {  System.out.println("TestB");  }     public static void main (string[]  args)  (     ((TestA)new TestB()).start();     )     }  运行结果是哪项?()     A、  TeStAB、  TeStBC、编译失败D、运行时抛出异常

public class Starter extends Thread {  private int x= 2;  public static void main(String[] args) throws Exception {  new Starter().makeItSo();  }  public Starter() {  x=5;  start();  }  public void makeItSo() throws Exception {  join();  x=x- 1;  System.out.println(x);  }  public void run() { x *= 2; }  }  What is the output if the main() method is rum?() A、 4B、 5C、 8D、 9E、 Compilation fails.F、 An exception is thrown at runtime.G、 It is impossible to determine for certain.

现有:  class Birds {  public static void main (String  []  args)  {   try {  throw new Exception () ;    } catch (Exception e) {   try {   throw new Exception () ;  }  catch  (Exception e2)  {  System.out.print ("inner           "); }   System. out.print ( "middle" ) ;    }  System.out.print ("outer") ;    }    }  结果是()A、 inner outerB、 middle outerC、 inner middle outerD、.编译失败

class Birds {  public static void main(String [] args) {  try {  throw new Exception();  } catch (Exception e) { try {  throw new Exception();  } catch (Exception e2) { System.out.print("inner "); }  System.out.print("middle "); }  System.out.print("outer ");  }  }  结果为:()  A、innerB、inner outerC、middle outerD、inner middle outer

现有:  class Banana2  f      static int X=2;  public static void main (String  []  args)  {     int X=2;   Banana2 b=new Banana2();     b.go(x);     }  static  {x+=x; }   void go (int x)  {    ++x;  System. out.println (x);    }         结果为:()    A、7B、5C、3D、2

单选题现有:  class Birds {  public static void main (String  []  args)  {   try {  throw new Exception () ;    } catch (Exception e) {   try {   throw new Exception () ;  }  catch  (Exception e2)  {  System.out.print ("inner           "); }   System. out.print ( "middle" ) ;    }  System.out.print ("outer") ;    }    }  结果是()A inner outerB middle outerC inner middle outerD.编译失败

单选题程序:  class   TestApp{  public  static  void main (String[]  args){     int x=6;     if (xl)  System. out. println("xl");     else if (x5)  System. out .println("x5");     else if (xSystem. out .println( "xAx5BxlCx10Dx29

单选题class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()A 0B 1C 2D Compilation fails.

单选题程序: class TestApp{ public static void main (String[] args){ int x=6; if (xl) System. out. println("xl"); else if (x5) System. out .println("x5"); else if (x10) System. out. println("xAx5BxlCx10Dx29

单选题现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()A1B2C3D编译失败

单选题class Birds {  public static void main(String [] args) {  try {  throw new Exception();  } catch (Exception e) { try {  throw new Exception();  } catch (Exception e2) { System.out.print("inner "); }  System.out.print("middle "); }  System.out.print("outer ");  }  }  结果为:()AinnerBinner outerCmiddle outerDinner middle outer

单选题现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()A  2B  3C  4D编译失败