网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
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 = 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.” 相关考题
考题
有下列程序:#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
考题
有下列程序: #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--)
考题
单选题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); }程序的运行结果是( )。A
5,0B
6,0C
5,-1D
6,-1
热门标签
最新试卷