网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

【分录题】写出下面程序运行结果。 public class Demo { public static void main(String args[]) { int x = 5, y = 10, r = 5; switch (x + y) { case 15: r += x; case 20: r -= y; case 25: r *= x / y; default: r += r; } System.out.println(r); } }


参考答案和解析
B 本题考查带参数的宏的定义:“#defineADD(x)x+x”中x代表m+n,故s写成s=m+n+m+n*k=1+2+1+2*3=10。
更多 “【分录题】写出下面程序运行结果。 public class Demo { public static void main(String args[]) { int x = 5, y = 10, r = 5; switch (x + y) { case 15: r += x; case 20: r -= y; case 25: r *= x / y; default: r += r; } System.out.println(r); } }” 相关考题
考题 设有如下程序: import java.util.*; public class Sun { public static void main(String args[ ]) { int score; String a; Random r=new Random(); score=r.nextInt(4)+5; switch(score) { case 0: a="E"; break; case 1: a="D"; break; case 2: a="C"; break; case 3: a="B"; break; default: a="A"; } System.out.println(A) ; } } 程序运行的结果是( )。A.a="A"B.aa"E" a="A"C.a="E"D.a="C"

考题 以下程序的运行结果为( )。 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

考题 执行下面程序段,屏幕上将输出( )。 public class Test { private int x=10,y=20; public Test (int x,int y) { System.out.println (x+this.x); System.out.println (y+y); } public static void main (String[] args) { Testt= new Test(30,50); } }A.无输出B.20 40C.40 100D.40 70

考题 执行下面程序后输出的正确结果是 public class Test{ public static void main(String args[]){ byte x=3,y=4; long r=80L; System.out.print(r/y); System.out.print(","); System.out.print(x/y); } }A.20.0,1B.20.0,1.0C.20,0D.20,1.0

考题 ( 18 )阅读下列程序Public class Test implements Runnable{Private int x=0;Private int y=o;boolean flag=true;Public static void main(string[ ] args) {Test r =new Test( );Thead t1=new Thead(r);Thead t2=new Thead(r);t1.start( );t2.start( );}Public void run(){While(flag) {x++;y++;system.out.println( “ ( ” +x_ “ , ” +y+ ” ) ” );if (x=10)flag=false;}}}下列对程序运行结果描述的选项中,正确的是A)每行的( x,y )中,可能有;每一对( x,y )值都出现两次。B)每行的( x,y )中,可能有;每一对( x,y )值仅出现一次。C)每行的( x,y )中,可能有 x=y ;每一对( x,y )值都出现两次。D)每行的( x,y )中,可能有 x=y ;每一对( x,y )值都出现一次。

考题 以下程序执行后的输出结果是( )。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[]) { byte y=4; long r=80L; System.out.println(r/y); } }A.20BB.20C.20D.编译错误

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

考题 有以下程序:includeusingnamespacestd;definePI3.14classPoint{private: intx,y;pub 有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a,int b,int c):Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<cl.area()<<endl; return 0; } 程序执行后的输出结果是A.314B.157C.78.5D.153.86

考题 若有程序: fun(int a,int b) { static int c=0; c+=a+b: return c; } main() { int x=5,y=3,z=7,r; r=fun((y,x+y),z); r=fun(x,y); printf("%d\n",r); } 上面程序的输出结果是______。A.23B.15C.19D.18

考题 若有程序 fun(int a,int b) { static int c=0 c+=a+b; retum c; } main () { int x=5,y=3,z=7,r; r=fun((y,x+y),z); r=fun(x,y); printf("%d\n",r); } 上面程序的输出结果______。A.23B.15C.19D.18

考题 阅读下面程序 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.xyz12B.xyz345C.xyzxyzD.12xyz

考题 下列程序执行的结果是______。 public class ex6 { public static void main(String[] args) { char ch='8'; int r=10; switch(ch+l) { case '7': r=r+3; case '8': r=r+5; case '9': r=r+6; break; default: ; } System.out.print(r); } }A.14B.13C.16D.10

考题 执行下面程序,显示的结果为( )。 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

考题 下列程序的执行结果是( )。 public class Testii{ public static void main(String arg[]){ byte y=4; long r==80L: System.out.println(r/y): } }A.20BB.20C.20.0D.编译错误

考题 下列程序的执行结果是 public class Testii { public static void main(String args[ ]) { byte y=4; long r=80L; System.out.pfinfln(r/y); } }A.20 BB.20C.20D.编译错误

考题 下面程序段的输出结果为( )。 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 exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }A.28B.21C.14D.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.编译错误

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

考题 以下程序执行后的输出结果是include using namespace std;void try(int,int,int,int) 以下程序执行后的输出结果是 #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<<endl; 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.不确定

考题 若有以下程序:include using namespace std;define PI 3.14class Point{private: in 若有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a, int b,int c) :Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<c1.area()<<end1; return 0; } 程序执行后的输出结果是( )。A.314B.157C.78.5D.153.86

考题 执行下面程序后输出的正确结果是 public class Test{ public stoic void main (String args[]){ byte x=3, y=4; long r=80L; System.out.print(r/y); System.out.print(","); System.out.print(x/y); } }A.20.0, 1B.20.0, 1.0C.20,0D.20, 1.0

考题 阅读下列程序: Public class Test implements Runnable{ Private int x=0l Private int y=0; boolean flag=true; Public static void main(string[]args){ Test r=new Test; Thead tl=new Thead(r); Thead t2=new Thead(r); tl.start; t2.start; } Public void run{ While(flag){ x++; y++; system.out.println("("+x-","+y+")"); if(x=10) flag=false; } } } 下列对程序运行结果描述的选项中,正确的是( )。A.每行的(x,y)中,可能有x≠y;每一对(x,y)值都出现两次B.每行的(x,y)中,可能有x≠y;每一对(x,y)值仅出现 一次C.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现两次D.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现

考题 下列程序的执行结果是 ( ) public class Testii { public static void main(String args[]) { byte y=4; long r=80L; System.out.println(r/y); } }A.20BB.20C.20.0D.编译错误

考题 若有程序fun(int a, int b){ static int c=0; c+=a+ b; returm c;}main(){ int x=5,y=3,z=7,r; r=fun((y, x+ y),z); r=fun (x, y); printf("%d\n", r);}A.23B.15C.19D.18

考题 以下程序执行后的输出结果是include.using namespace std;void try(int,int,int,int) 以下程序执行后的输出结果是 #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.不确定

考题 class DemoApp{  public static void main(String[] args){  int x = 5; int y = ++x + x++; S ystem.out.println(“y=”+y+”,x=”+x);  }  }  以上程序运行后的输出结果是哪项?() A、y=10,x=5B、y=11,x=6C、y=12,x=7D、y=11,x=7