单选题int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()A x = 6 y = 0B x = 7 y = 0C x = 6 y = -1D x = 7 y = -1E Compilation fails.

单选题
int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()
A

 x = 6 y = 0

B

 x = 7 y = 0

C

 x = 6 y = -1

D

 x = 7 y = -1

E

 Compilation fails.


参考解析

解析: A ‘while’ statement can only evaluate a Boolean expression. The expression while(y--) returns an int rather than a Boolean. Therefore, the correct answer is E. 

相关考题:

下列循环的循环体将被执行( )。 int x =10, y=30; dot y -= x; x++; while (x++>y--);A.0次B.1次C.2次D.3次

有下列程序:#include"stdio.h"main(){ int x=0;int y=0;while(x<7++y){ y--;x++;}printf("%d,%d",y,x);}程序的输出结果是( )。A.0,7B.7,7C.0,6D.1,6

有如下程序:void main(){int x=2,y=3,a,b,c,d;a=(x++>=--y);b=(x==++y);c=(x--!=y);d=(++x>y--);}则程序执行后变量a,b,c,d的值分别是______。

有如下程序:includevoid main(){int x=2,y=3,a,b,c,d;a=(x++>=--y);b=(x==++y);c=(x 有如下程序:include<iostream.h>void main(){int x=2,y=3,a,b,c,d;a=(x++>=--y);b=(x==++y);c=(x--!=y);d=(++x>y--);Cout<<a<<b<<c<<d<<end1;}则程序执行后变量a,b,c,d的值分别是【 】。

下面程序的运行结果是()。includemain(){int y=10; do{y--;}while(--y); printf("%d\n" 下面程序的运行结果是( )。 #include<stdio.h> main() { int y=10; do{y--;}while(--y); printf("%d\n",y--); }A.-1B.1C.8D.0

intx=1,y=6;while(y--){x++;}System.out.println(x=”+x+y=”+y);Whatistheresult?() A.x=6y=0B.x=7y=0C.x=6y=-1D.x=7y=-1E.Compilationfails.

下面程序的运行结果是______。includemain(){ int y,a;y=2,a=1;while(y--!=-1){do{a*=y; 下面程序的运行结果是______。include<stdio.h>main(){ int y,a;y=2,a=1;while(y--!=-1){do{a*=y;a++;}while(y--);}printf("%d,%d",a,y);}

下面程序的输出是________。 main() {int x=3,y=6,a=0; while(x++!=(y=|)) { a+=1; if(y<x)break; } printf("x=%d,y=%d,a=%d\n",x,y,A) ; }A.x=4,y=4,a=1B.x=5,y=5,a=1C.x=5,y=4,a=3D.x=5,y=4,a=1

执行下列程序后的输出结果是______。main(){ int y=10; do {y--;}while(--y); printf("%d\n",y--);}A.-1B.1C.8D.0

下面程序的输出是______。 main() {int x=3,y=6,a=0; while(x++!=y-=1)) { a+=1; if(y<x)break; } printf("x=%d,a=%d\n",x,y,A) ; }A.x=4,y=4,a=1B.x=5,y=5,a=1C.x=5,y=4,a=3D.x=5,y=,a=1

下面程序的输出是______。 main() {int x=3,y=6,a=0; while(x++!=(y-=1)) { a+=1 if(y<x)break; } printf("x=%d,y=%d,=%d\n",x,y,a); }A.x=4,y=4,a=1B.x=5,y=5,a=1C.x=5,y=4,a=3D.x=5,y=4,a=1

下列语句序列执行后,k的值是______。 int x=10,y=30; do{ y-=x; X++; }while(x++<y--);A.0次B.1次C.2次D.3次

有下列程序: #include " stdio.h" main() { int x=0; int y=0; while (x<7++y) { y--; x++;} printf("%d,%d",y,x); } 程序的输出结果是( )。A.0, 7B.7, 7C.0,6D.1,6

下列程序的输出结果是______。#includemain(){ char *a="abcdefghi";int k; fun(a);puts(a);}fun(char*s){ int x,y;char c; for(x=0,y=strlen(s)-1;x<y;x++,y--) { c=s[y];s[y]=s[x];s[x]=c;}}A.ihgfsdcbaB.abcdcfghiC.abcdedebaD.ihgfefghi

有下列程序:#includestdio.hmain{ int x=0;int y=0;while(x7 &&++y){ y--;x++;}printf(%d,%d,y,x);}程序的输出结果是( )。A.0,7B.7,7C.0,6D.1,6

有下列程序: #includestdio.h main { int x=0; int y=0; while(x7 &&++v) { y--; x++;} printf("%d,%d",y,x); } 程序的输出结果是( )。A.0,7B.7,7C.0,6D.1,6

下面程序的输出结果是()。includevoid main(){int x=-1,y=5,z;z=(x++ 下面程序的输出结果是( )。#include<iostream.h>void main(){int x=-1,y=5,z;z=(x++<0) (y-->=0);cout<<x<<'\t'<<y<<'\t'<<z<<end1;}A.-1 5 0B.-1 4 1C.0 4 1D.0 4 0

int x=0;  int y 10;  do {  y--;  ++x;  } while (x  5);  System.out.print(x + “,“ + y);  What is the result?() A、 5,6B、 5,5C、 6,5D、 6,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、6B、7C、8D、10

设x=4,y=8,说明下列各题运算后x,y,z的值分别是多少? (a)z=(++x)*(--y) (b)z=(++x)+(y--) (c)z=(x++)*(--y) (d)z=(x++)+(y--)

int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()  A、 x = 6 y = 0B、 x = 7 y = 0C、 x = 6 y = -1D、 x = 7 y = -1E、 Compilation fails.

Which two code fragments are most likely to cause a StackOverflowError?()A、int []x = {1,2,3,4,5};for(int y = 0; y  6; y++)    System.out.println(x[y]);B、static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }C、for(int y = 10; y  10; y++)doStuff(y);D、void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }E、for(int x = 0; x  1000000000; x++) doStuff(x);F、void counter(int i) { counter(++i); }

问答题设x=4,y=8,说明下列各题运算后x,y,z的值分别是多少? (a)z=(++x)*(--y) (b)z=(++x)+(y--) (c)z=(x++)*(--y) (d)z=(x++)+(y--)

单选题int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()A x = 6 y = 0B x = 7 y = 0C x = 6 y = -1D x = 7 y = -1E Compilation fails.

单选题public class WhileFoo {  public static void main (String []args)   {  int x= 1, y = 6;  while (y--)  {x--;}  system.out.printIn(“x=” + x “y =” + y);  }  }   What is the result?()A The output is x = 6 y = 0B The output is x = 7 y = 0C The output is x = 6 y = -1D The output is x = 7 y = -1E Compilation will fail.

多选题Which two code fragments are most likely to cause a StackOverflowError?()Aint []x = {1,2,3,4,5};for(int y = 0; y  6; y++)    System.out.println(x[y]);Bstatic int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }Cfor(int y = 10; y  10; y++)doStuff(y);Dvoid doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }Efor(int x = 0; x  1000000000; x++) doStuff(x);Fvoid counter(int i) { counter(++i); }

单选题int x=0;  int y 10;  do {  y--;  ++x;  } while (x  5);  System.out.print(x + “,“ + y);  What is the result?()A 5,6B 5,5C 6,5D 6,6

单选题有以下程序:#include main(){ int x=0,y=6;  do {  while(--y)x++; } while(y--); printf(%d,%d,x,y); }程序的运行结果是(  )。A5,0B6,0C5,-1D6,-1