更多"有如下程序 public class Sun public "的相关试题:
[单项选择]有如下程序
public class Sun
public static void main(String args[ ])
int x=0;
int n=0;
while(x<50)
x=(x+2)*(x+3);
n=n+1;
System.out.println(n+"和"+x);
上述程序的运行结果是( )。
A. 1和0
B. 2和72
C. 3和50
D. 4和168
[单项选择]有以下程序
public class Sun
public static void main(string args[ ])
int a, b;
for(a=1, b=1; a<=100; a++)
if(b>=10)
break;
if (b%3==1)
b+=3;
continue;
System.out.println(
A. ;
B. 6
C. 5
D. 4
[单项选择]有如下程序:
public class Sun
public static void main(String args[ ])
int s=0;
int i=1;
while (i<=100)
s=s+i;
System.out.println(s);
运行后的结果是( )。
A. 5050
B. 5051
C. 死循环,直到溢出
D. 无穷大的数
[单项选择]设有如下程序:
public class Sun
public static void main(String args[ ])
int x, y;
x-4;
y=0;
if(Math.pow(x,2)==16)
y=x;
if(Math.pow(x,2)<15)
y=1/x;
if(Math.pow(x,2)>15)
y=(int)Math.pow(x,2)+1;
System.out.println(y);
程序的运行结果是( )。
A. 4
B. 17
C. 18
D. 0.25
[单项选择]阅读下面程序
public class Test4
public static void main (String args[])
int i=10, j=3;
float m=213.5f,n=4.0f
System.out.printIn (i%j);
System.out.printIn (m%n);
程序运行的结果是______。
A. 1.0和1.5
B. 1和1.5
C. 1.0和2.5
D. 1和2.5
[单项选择]有如下程序 public class Sun { public static void main(String args[ ]) { int x=1,a=0,b=0; switch(x) { case 0:b++; case 1:a++; case 2: a++; b++; } System.out.println("a="+a+","+"b="+B) } }该程序的输出结果是( )。
A. a=2,b=1
B. a=1,b=1
C. a=1,b=0
D. a=0,b=0
[单项选择]设有如下程序:
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>y
B. x=y
C. x<y
D. 以上都不对
[单项选择]有以下程序 public class Sun { public static void main(string args[ ]) { int a, b; for(a=1, b=1; a<=100; a++) { if(b>=10} break; if (b%3 1) { b+=3; continue; } } System.cut.println(A) ; } } 执行后的输出结果是( )。
A. 101
B. 6
C. 5
D. 4
[单项选择]执行如下程序:
public class Test
public static void main (String args[])
int x=1,a=0,b=0;
switch (x)
case 0: b++;
case 1: a++;
case 2: a++;b++;
System.out.println("a=" +a ",b=" +b);
该程序的输出结果是( )。
A. a=2,b=1
B. a=1,b=1
C. a=1,b=0
D. a=2,b=2
[填空题]若有如下程序:
public class Test
public static void main (String[] args)
int x=20;
if (x>10) System.out.print(x-=5);
if (x>5) System.out.print(x--);
则程序运行后的输出结果是 【12】 。
[单项选择]阅读下面程序
public class Increment
public static void main (String args[]
int c;
c=5;
System.out.printIn(c);
System.out.printIn(c++)j
System.out.printIn (c);
程序运行结果是______。
A. 5
B. 5
C. 6
D. 6
[单项选择]阅读下面程序
public class MyVal
public static void main(String[]args)
MyVal m=new MyVal( );
m.amethod( );
public void amethod( )
boolean b[]=new Boolean[5];
程序编译或运行的结果是
A. 1
B. null
C. ""
D. 编译不通过