单选题int x = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()Ax=1Bx=3CCompilationensp;fails.DTheensp;codeensp;runsensp;withensp;noensp;output.ensp;EAnensp;exceptionensp;isensp;thrownensp;atensp;runtime.

单选题
int x = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()
A

x=1

B

x=3

C

Compilation fails.

D

The code runs with no output. 

E

An exception is thrown at runtime.


参考解析

解析: 暂无解析

相关考题:

以下选项错误的是A.main(){ int x,y,z;x=0;y=x-1;z=x+y;}B.main(){ int x,y,z;x=0,y=x+1;z=x+y;}C.main(){ int x;intint y;x=0,y=x+1;z=x+y;}D.main(){ int x,y,z;x=0;y=x+1;z=x+y,}

有以下程序:includeint f(int x){int y;if(x==0||x==1)return(3);y=x*x-f(x-2);return 有以下程序: #include<stdio.h> int f(int x) {int y; if(x==0||x==1)return(3); y=x*x-f(x-2); return y; } main() {int z; z=f(3);printf("%d\n",z); } 程序的运行结果是( )。A.0B.9C.6D.8

下面程序段的输出结果是( )。 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.编译错误

以下程序执行后的输出结果是( )。include usingnamespacestd;void try(int,int,int,in 以下程序执行后的输出结果是( )。 #include <iostream> using namespace std; void try(int,int,int,int); int main ( ) { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = X*X; y = y*y; r = z+x+y; }A.18B.9C.10D.不确定

下面程序段的输出结果是( )。 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(xv) System.OUt.println("xy"); elseif(x= =y) System.out.println("x=Y"); else System.out.println("xy"): } }A.xyB.x=YC.xyD.编译错误

下列函数定义中,会出现编译错误的是 ______。A.max(int x,int y,int *z) { *z=x>y? x:y;}B.int max(int x,y) {int z; z=x>y? x;y; return z; }C.max(int x,int y) { int z; z=x>y? x:y; return(z); }D.int max(int x,int y) { return(x>y?x:y);}

下列函数定义中,会出现编译错误的是A.max(int x,int y,int *z) { *z=xy ? x:y; }B.int max(int x,y) { int z; z=x>y ? x:y; return z; }C.max(int x,int y) { int z; z=xy?x:y; return(z); }D.int max(int x,int y) { return(x>y?x:y); }

下列程序执行后,屏幕的输出是()。includeusing namespace std;void swap(int x,int y) 下列程序执行后,屏幕的输出是( )。 #include<iostream> using namespace std; void swap(int x,int y) { int temp=x; x=y; y=temp; cout<<"x="<<x<<"",y=""<<y<<end1; } int main() { int x=3,y=2; swap(x,y); cout<<"x="<<x<<",y="<<y<<end1; return 0; }A.x=3,y=2 x=3,y=2B.x=2,y=3 x=3,y=2C.x=2,y=3 x=2,y=3D. x=3,y=2 x=2,y=3

有如下程序: include using namespace std; void f1(int x, int y){int z= 有如下程序:#include<iostream>using namespace std;void f1(int x, int y){int z=x; x=y; y=z;)void f2(int x, int y){int z=x; x=y; y=z;}intmain(){int x=10, y=26;f1(x, y);f2(x, y);cout<<y<<end1;return 0;}运行时的输出结果是( )。A) 10B) 16C) 26D) 36A.B.C.D.

下面程序段的输出结果是 public class Test{ public static void main(Stringargs[]){ int x,y; x=(int)Math.sqrt(5)/2+(int)Math.random()*5/2; y=(int)Math.sqrt(3)/2+(ht)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.编译错误

主调函数中的两个变量a和b,要求调用函数交换a、b的值,返回交换结果,则以下正确的函数是______。A.funa(int*x,int*y) {int*p; *p=*x;*x=*y;*y=*p; }B.funb(int x,int y) {int t; t=x;x:y=y=t;}C.func(int*x,int*y) {*x=*y;*y=*x;}D.fund(int *x,int*y) {*x=*x+*y;*y=*x-*y;*x=*x-*y;}

下列程序段执行后的输出结果为( )。 int x=3; int y=10; System.out.println(y%x);A.0B.1C.2D.3

设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

下列程序的执行结果是()。 includeclass Sample{ int x,y; public: Sample() {x=y=0 下列程序的执行结果是( )。 #include<iostream.h> class Sample { int x,y; public: Sample() {x=y=0;} Sample(int a,int b) {x=a;y=b;} ~Sample() { if(x==y) cout<<"x=y"<<end1; else cout<<"x!=y"<<end1; } void disp() { cout<<"x="<<x<<",y="<<y<<end1; } }; void main() { Sample s1(2,3); s1.disp(); }A.x=2,y=2B.x=3,y:3C.x=2,y=3D.x=3,y=2

下列程序的输出结果是( )。void fun(int*X,int y){ printf(%d%d,*x,*y);*x=3;*y=1;}main{ int x=1,y=2;fun(&y,&x);printf(%d%d,x,y);}A.2 1 4 3B.1 2 1 2C.1 2 3 4D.2 1 1 2

设有如下程序: public class Sun { public static void main (String args[ ]) { int x,y; x= (int) Math.sqrt (2) /2+ (int) Math.random ()*2/2; y= (int) Math.sqrt (3) /3+ (int) Math.random ()*3/3; 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.以上都不对

下面程序段的输出结果是( )。 publicclassTest{ publicstaticvoidmain(Stringargs[]){ intx,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.println9"x>y"); elseif(x==y) System.out.println("x=y"); else System.out.println("x<y"); } }A.x>yB.x=yC.x<yD.编译错误

下列程序的输出结果是______。 int x=3; int y=10; System.out.println(y%x);A.0B.1C.2D.1.0

下面程序段的输出结果是______。 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.编译错误

下列函数定义不正确的是 ( )A.int max { int x y,z; z=x>y? x: y }B.int max(x,y) int x,y; { int z; z=x>y? x:y; return(z) }C.int max(x,y) { int x,y z; z=x>y? x: y; return(z); }D.int max( ) {}

以下程序执行后的输出结果是includeusing namcspace std;void try(int,int,int,int); 以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }A.18B.9C.10D.不确定

下列带缺省值参数的函数说明中,正确的说明是 ______。A.int Fun(int x, int y=2,int z=3);B.int Fun(int x=1,int y,int z=3);C.int Fun(int x, int y=2,iht z);D.int Fun(int x=1,int y, int z=3);

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

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 = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()A、x=1B、x=3C、Compilationensp;fails.D、Theensp;codeensp;runsensp;withensp;noensp;output.ensp;E、Anensp;exceptionensp;isensp;thrownensp;atensp;runtime.

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); }

多选题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); }