单选题现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &&  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }     

题目
单选题
现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &&  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }      结果是什么?()
A

Z=21

B

Z=22

C

Z=23

D

Z= 24


相似考题
更多“单选题现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }      ”相关问题
  • 第1题:

    现有:classTest4{publicstaticvoidmain(String[]args){booleanX=true;booleany=false;shortZ=42;if((z++==42)&&(y=true))z++;if((x=false)||(++z==45))z++;System.out.println(¨z=”+z);}}结果为:()

    A.Z=42

    B.z=44

    C.Z=45

    D.z=46


    参考答案:D

  • 第2题:

    下列语句输出结果为( )。 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.1

    D.0


    正确答案:B

  • 第3题:

    阅读下面程序 public class Test3 { public static void main(String[] args) { int x=3,y=4,z=5; String s="xyz": System.out.println(s+x+y+z); } } 程序运行的结果是

    A.xyz12

    B.xyz345

    C.xyzxyz

    D.12xyz


    正确答案:B
    解析:Java中对+运算符的功能进行了扩展,使其能够进行字符串连接。如"xyz"+"rst"结果为"xyzrst","xyz"+3结果为"xyz3"。如果运算符+的第一个操作数不是字符串,则运算结果由后续的操作数决定,如3+4+5+"xyz"的结果是"12xyz",而不是"345xyz"。

  • 第4题:

    下列语句输出结果为( )。 public class test { public static void main(String args[ ]) { int x=10,y=8; boolean b=true; System.out.println(x>0&&x<y||b); } }

    A.真

    B.假

    C.1

    D.0


    正确答案:A

  • 第5题:

    现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &&  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }      结果是什么?()     

    • A、Z=21
    • B、Z=22
    • C、Z=23
    • D、Z= 24

    正确答案:B

  • 第6题:

    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、6
    • B、7
    • C、8
    • D、10

    正确答案:C

  • 第7题:

    public class Yikes {  public static void go(Long n) {System.out.println(”Long “);}  public static void go(Short n) {System.out.println(”Short “);}  public static void go(int n) {System.out.println(”int “);}  public static void main(String [] args) {  short y= 6;  long z= 7;  go(y);  go(z);  }  }  What is the result?() 

    • A、 int Long
    • B、 Short Long
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第8题:

    public class Wow {  public static void go(short n) {System.out.println(”short”); }  public static void go(Short n) {System.out.println(”SHORT”);}  public static void go(Long n) {System.out.println(” LONG”); }  public static void main(String [] args) {  Short y= 6;  int z=7;  go(y);  go(z);  }  }  What is the result?() 

    • A、 short LONG
    • B、 SHORT LONG
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:C

  • 第9题:

    单选题
    现有:  class  Test4  {  public static void main (String  []  args)  {    boolean X=true;   boolean y=false;    short Z=42;    if((z++==42)  &&  (y=true))z++;    if((x=false)  ||    (++z==45))  z++;    System. out.println(¨z=”+z);     }    }  结果为:()
    A

      Z=42

    B

      z=44

    C

      Z= 45

    D

      z= 46


    正确答案: A
    解析: 暂无解析

  • 第10题:

    单选题
    现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &&  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }      结果是什么?()
    A

    Z=21

    B

    Z=22

    C

    Z=23

    D

    Z= 24


    正确答案: C
    解析: 暂无解析

  • 第11题:

    单选题
    class Test4 {   public static void main(String [] args) {   boolean x = true;   boolean y = false;   short z = 42;   if((z++ = = 42) && (y = true)) z++;   if((x = false) || (++z = = 45)) z++;   System.out.println("z = " + z);   }   }   结果为:()
    A

    z = 42

    B

    z = 44

    C

    z = 45

    D

    z = 46


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    现有:  class Foo  {  public static void main (String  []  args)  {      int x=O;      int y=4;  for (int  z=0;  z1&++y<10)    y++;    }  System. out .println (y);  }   }  结果是什么?()
    A

    7

    B

    8

    C

    10

    D

    12


    正确答案: A
    解析: 暂无解析

  • 第13题:

    执行下列代码段之后,变量b的值为______。 public class ex40 { public static void main(String[] args) { byte x=5; byte y=5; byte c=10; boolean b; b-c<x<<y; System.out.println (b); } }

    A.1

    B.0

    C.false

    D.true


    正确答案:D

  • 第14题:

    执行下列代码段之后,变量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.1

    B.2

    C.3

    D.4


    正确答案:D
    解析:表达式中的运算次序应该是先对y做减量运算,得到y=2,然后再取x的值x=2,做减法运算得到0,最后用z减去0,得到答案为4。

  • 第15题:

    下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+B); c=(b==false); System.out.println("b="+b+"c="+C); } }

    A.a=true b=false b=true c=false

    B.a=true b=false b=true c=true

    C.a=true b=true b=true c=false

    D.a=false b=false b=true c=false


    正确答案:C
    解析:本题考查关系运算符和==。题目中a=(35);比较3和5的大小,因为 35,返回true给a;b=(a==true);判断a是否为真,因为a确实为真,返回true给b;c=(b==false);判断 b是否为假,因为b不为假,返回false给c。最后结果a=true,b=true,b=true,c=false,选项C正确。

  • 第16题:

    下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.printin( "a="+a+"b="+b) ; c-(b==false); System.out.println(b="+b+"e="+c) ; } }

    A.a=true b=false b=true c=false

    B.a=true b=false b=true c=true

    C.a=true b=true b=true c=false

    D.a=false b=false b=true c=false


    正确答案:C
    解析:本题考查关系运算符和==。题目中a=(35);比较3和5的大小,因为35,返回true给a:b=(a==true);判断a是否为真,因为a确实为真,返回true给b;c=(b==false);判断b是否为假,因为b不为假,返回false给c。最后结果a=true,b==true,b=true,c=false,选项C正确。

  • 第17题:

    现有:  class  Test4  {  public static void main (String  []  args)  {    boolean X=true;   boolean y=false;    short Z=42;    if((z++==42)  &&  (y=true))z++;    if((x=false)  ||    (++z==45))  z++;    System. out.println(¨z=”+z);     }    }  结果为:() 

    • A、  Z=42
    • B、  z=44
    • C、  Z= 45
    • D、  z= 46

    正确答案:D

  • 第18题:

    现有:  class Foo  {  public static void main (String  []  args)  {      int x=O;      int y=4;  for (int  z=0;  z<3;  Z++;  X++)  {     if(x>1&++y<10)    y++;    }  System. out .println (y);  }   }  结果是什么?()     

    • A、7
    • B、8
    • C、10
    • D、12

    正确答案:B

  • 第19题:

    class Test2{   public static void main(String [] args){   boolean x=true;   boolean y=false;   short z=42;   if((x==true)&&y=true))z++;   if((y==true||++z=44))z++;   System.out.println(“z=”+z);  }  }   结果是什么?()  

    • A、 z=42
    • B、 z=43
    • C、z=44
    • D、 z=45
    • E、编译失败
    • F、运行的时候有异常抛出

    正确答案:D

  • 第20题:

    class Test4 {   public static void main(String [] args) {   boolean x = true;   boolean y = false;   short z = 42;   if((z++ = = 42) && (y = true)) z++;   if((x = false) || (++z = = 45)) z++;   System.out.println("z = " + z);   }   }   结果为:()  

    • A、z = 42
    • B、z = 44
    • C、z = 45
    • D、z = 46

    正确答案:D

  • 第21题:

    单选题
    public class Yikes {  public static void go(Long n) {System.out.println(”Long “);}  public static void go(Short n) {System.out.println(”Short “);}  public static void go(int n) {System.out.println(”int “);}  public static void main(String [] args) {  short y= 6;  long z= 7;  go(y);  go(z);  }  }  What is the result?()
    A

     int Long

    B

     Short Long

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: D
    解析: 暂无解析

  • 第22题:

    单选题
    class Test2{   public static void main(String [] args){   boolean x=true;   boolean y=false;   short z=42;   if((x==true)&&y=true))z++;   if((y==true||++z=44))z++;   System.out.println(“z=”+z);  }  }   结果是什么?()
    A

     z=42

    B

     z=43

    C

    z=44

    D

     z=45

    E

    编译失败

    F

    运行的时候有异常抛出


    正确答案: A
    解析: 暂无解析

  • 第23题:

    单选题
    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

    6

    B

    7

    C

    8

    D

    10


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    public class Wow {  public static void go(short n) {System.out.println(”short”); }  public static void go(Short n) {System.out.println(”SHORT”);}  public static void go(Long n) {System.out.println(” LONG”); }  public static void main(String [] args) {  Short y= 6;  int z=7;  go(y);  go(z);  }  }  What is the result?()
    A

     short LONG

    B

     SHORT LONG

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: A
    解析: 暂无解析