123456
123455
123450
编译错误
第1题:
A.123456
B.123455
C.123450
D.编译错误
第2题:
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}
A.编译错误
B.0
C.1
D.运行成功,但不输出
第3题:
下列程序的功能是为变量赋值,程序运行后,输出i=51。请改动main方法中的错误,使程序能够正确编译、运行并输出正确的结果。
注意:不改动程序结构。
class A
{
private int a;
public void setA (int x)
{
a=x;
}
public int getA()
{
return a;
}
}
public class MethodTest
{
public static void main(String args[])
{
A a=A();
a.getA(51);
int i=a.getA();
System.out.println ("i="+i);
}
}
第4题:
下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}
A.0
B.2
C.3
D.4
第5题:
下列程序执行后的结果是______。
public class ex24
{
public static void main(String[] args)
{
int j=10;
a1: for(int i=3;i>0;i--)
{
j-=i;
int m=l;
a2: while (m<j)
{
if (i<=m)
continue a1;
j/=m++;
}
}
System.out.println(j);
}
}
下列嵌套的循环程序执行后,结果是______。 public class ax25 { public static void main(String[] args) { int sum=0; for(int i=0;i<=5;i++) { for(int j=10;j>3*i;j--) { sum+=j*i; } } System.out.println(sum); } }
A.136
B.127
C.147
D.153
第6题:
A.123456
B.123455
C.123450
D.编译错误
第7题:
下面代码的运行结果是 public class Test{ public static void main(String args[]){ for(int i=0; i<3;i++){ if(i<2) continue; System.out.println(i); } } }
A.0
B.1
C.2
D.3
第8题:
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }
A.编译错误
B.0
C.1
D.运行成功,但不输出
第9题:
有下面程序段: Public class ArrayTest { Public static void main(String args[]) { int[] intArray=new int[3]; for(int I=0;I<3;I++) { intArray[I]=I+2; System.out.println("IntArray["+I+"]"="+intArray[I]); } System.out.println("--------------"); Int arrLen=4; IntArray=new int[arrLen]; For(int j=intArray.length;j>=0;j--) { intArray[j]=j*3; System.out.println("hello"+intArray[j]); } } } 则运行的结果是( )。
A.编译出错
B.编译通过,但运行出错
C.可以运行,但有错误
D.以上都不对
第10题:
下列程序的输出结果是( )。 public class ArrayTest { public static void main(String args[]) { int[]intArray=new int[3] for(int i=0;i<3;i++) { intArray[i]=i+2: system.out.println("lntArray["+i+"]¨= intArray[i]); } System.out.println("----------"); int arrlen=4: IntArray=new int[arrLen]; For(int j=intArray.length;j>=0;j--) { intArray[j]=j*3; system.out.println("hello"+intArray[j]); } } }
A.编译未通过
B.编译通过,但运行错误
C.可以运行,但有错误
D.以上都不对