class TestMain {   static int x = 2;   static { x = 4; }   static public void main(String[] args) {   int y = x + 1;   System.out.println(y);  }  }   和命令行:   java TestMain   结果为:()A、 3B、 5C、 编译失败D、 运行时异常被抛出

class TestMain {   static int x = 2;   static { x = 4; }   static public void main(String[] args) {   int y = x + 1;   System.out.println(y);  }  }   和命令行:   java TestMain   结果为:()

  • A、 3
  • B、 5
  • C、 编译失败
  • D、 运行时异常被抛出

相关考题:

以下程序的运行结果为( )。 public class Sun { public static void main(String args[]) { String x="A",y="B",z="C"; for(int m=1;m<=2;m++) { x=y; y=z; z=x; } System.out.println(x+y+z); } }A.ABCB.BCAC.BCBD.CBC

classTestMain{staticintx=2;static{x=4;}publicstaticvoidmain(String...args){inty=x+1;System.out.println(y);}}和命令行:javaTestMain结果为:() A.3B.5C.编译失败D.运行时异常被抛出

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

下列语句输出结果为( )。 public class test { public static void main (String args[]) { int x=10,y=9; boolean b=true; System.out.println(x<y||!b); } }A.真B.假C.1D.0

执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }A.1B.2C.3D.4

设x和y均为int型变量,则执行下面的循环后,y值为( )。 public class Sun { public static void main(String args[ ]) { int x, y; for (y=1, x=1; y<=50; y++) { if(x>=10) break; if (x%2==1) { x+=5; continue; } x-=3; } System.out.println (y); } }A.2B.4C.6D.8

执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23

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

下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int x,y; x=(int)Math.sqrt(5/2)+(int)Math.random( )*5/2; y=(int)Math.sqrt(3/2)+(int)Math.random( )*3/2; if(x>y) System.out.println("x>y"); else if(x==y) System.out.println("x=y"); else System.out.println("x<y"); } }A.x>yB.x=yC.x<yD.编译错误

下面程序段的输出结果为 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.编译不通过

有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。A.x=10B.x=20C.x=6D.编译不通过

下列代码执行之后,输出的结果为______。 public class ex38 { public static void main(String[] args) { int x=12; int m=11; int y=13; int temp=x>y?x:y; temp=temp>m?temp:m; System.out.println (temp); } }A.1B.12C.13D.11

Less Test{    public static void main(String[] args){   for(int x=0;x7;++x){  int y=2;   x=++y;   }   System.out.println(“y=”+y);   }   }   结果为:()  A、y=5B、y=6C、 y=7D、y=8E、编译失败F、运行时异常被抛出

import java.util.*;  class Banana3 {  public static void main(String [] args) {  int x = 2;  Banana3 b = new Banana3();  b.go(x);  }  static { x += x; }  void go(int x) {  ++x;  System.out.println(x);  }  }  结果为:()  A、2B、3C、5D、编译失败

现有:  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 WhileTests  {  public  static void main (String  []  args)  {      int X=5;  while (++x4)  {      --x;     }  System.out.println( "x="+x);      }      } 结果是什么?()     A、X=6B、X=5C、X=2D、编译失败

class Foo {  public static void main(String [] args) {  int x = 0;  int y = 4;  for(int z=0; z 〈 3; z++, x++) {  if(x 〉 1  ++y 〈 10) y++;  }  System.out.println(y);  }  }  结果是什么?()  A、6B、7C、8D、10

现有:  class TestMain {   static int x = 2;   static { x = 4; }   public static void main(String... args) {   int y = x + 1;   System.out.println(y);   }   }   和命令行:   java TestMain   结果为:()  A、 3B、 5C、 编译失败D、 运行时异常被抛出

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 WhileTests { public static void main(String [] args) {  int x = 5;  while (++x 〈 3) {  --x;  }  System.out.println("x = " + x);  }  } 结果是什么?()A、x = 2B、x = 5C、x = 6D、编译失败

import java.io.PrintWriter;  class DoFormat {  public static void main(String [] args) { int x = 42; int y = 12345;  float z = 7; System.out.format("-%4d- ", x);  System.out.format("-%4d- ", y);  System.out.format("-%4.1d- ", z); } }  结果为:() A、编译失败B、-42- -1234- -7.0-C、- 42- -1234- - 7.0-D、运行时异常被抛出

单选题现有:   class TestMain {       static int x = 2;    static { x = 4; }   public static void main(String... args) {     int y = x + 1;   System.out.println(y);   }   }    和命令行:  java TestMain    结果为:()A 3B 5C 编译失败D 运行时异常被抛出

单选题Less Test{    public static void main(String[] args){   for(int x=0;x7;++x){  int y=2;   x=++y;   }   System.out.println(“y=”+y);   }   }   结果为:()Ay=5By=6C y=7Dy=8E编译失败F运行时异常被抛出

单选题现有:   class TestMain {      static int x = 2;  static { x = 4; }   static public void main(String[] args) {    int y = x + 1;   System.out.println(y);    }    }    和命令行:  java TestMain    结果为:()A 3B 5C 编译失败D 运行时异常被抛出

单选题import java.util.*;  class Banana3 {  public static void main(String [] args) {  int x = 2;  Banana3 b = new Banana3();  b.go(x);  }  static { x += x; }  void go(int x) {  ++x;  System.out.println(x);  }  }  结果为:()A2B3C5D编译失败

单选题import java.io.PrintWriter;  class DoFormat {  public static void main(String [] args) { int x = 42; int y = 12345;  float z = 7; System.out.format("-%4d- ", x);  System.out.format("-%4d- ", y);  System.out.format("-%4.1d- ", z); } }  结果为:()A编译失败B-42- -1234- -7.0-C- 42- -1234- - 7.0-D运行时异常被抛出

单选题现有:  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编译失败