下面程序段的输出结果是 public class Test{ public static void main(String args[]){ int[]a=new int[11]; int[]p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i] for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
A.37
B.31
C.33
D.35
第1题:
顺序执行下面的语句后,输出的结果是______。
public class exl6
{
public static void main(String[] args)
{
int i;
int a[] = new int[10];
for(i = O; i < a.length; i++)
a[i] = i * 10 + j;
for(i = 1; i < a.length; i++)
if(a[i]%5 == O)
System,out.println(a[i]);
}
}
第2题:
下面程序段的输出结果是( )。 public class Test { public static void main ( String[] args) { int result=0; for ( int i=1;i<=5;i++) { if ( i%2==0 ) continue; result + =i; } System. out. println ("result is " + result ); } }
A.result is 7
B.result is 8
C.result is 9
D.result is 10
第3题:
下列代码的执行结果是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.运行成功,但不输出
第4题:
下面程序段的输出结果是( )。 public class Test t public static void main(String[] args) { int x=0; for (int i=1;i<=4;i++) { x=4; for(int j=1;j<=3; j++) { x=3; for(int k=1; k<=2; k++) x=x+6; } } System. out. println (x); } }
A.36
B.48
C.144
D.15
第5题:
有以下程序 #include <stdio.h> void fun(int a[],int n) { int i,t; for(i=0;i<n/2;i++) {t=a[i]; a[i]=a[n-1-i]; a[n-1-i]=t;} } main() {int k[10]={1,2,3,4,5,6,7,8,9,10},i; fun(k,5); for(i=2;i<8;i++) printf("%d",k[i]); printf("\n"); } 程序的运行结果是______。
A.345678
B.876543
C.1098765
D.321678
第6题:
下列程序执行后的结果是______。
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
第7题:
下面程序的输出为【 】。
include <iostream.h>
void main()
{
int a[10],i, k=0;
for(i=0,i<10;i++)
a[i]=i;
for(i=1;i<4;i++)
k+=a[i]+i;
cout<<k<<end1;
}
第8题:
分析以下程序的执行结果【 】。
include <iostream. h>
class S{
int A[10];
public:
int &operator () (int);
};
int &S: :operator() (int x) {
return A[x];
}
void main() {
S a;
int i,j;
for (i=0; i<10; i++)
a(i)=i*2;
for (i=0; i<10; i++)
cout<<a(i)<<" ";
cout<<end1; }
第9题:
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k);; } }
A.33
B.28
C.35
D.37
第10题:
下列代码的执行结果是( )。
public class Test{
public int aMethod( ){
static int i=0;
i++;
System.out.println(i):
}
public static void main (String args[]){
Trest test=new Test ( );
test aMethod( ):
}
}
A.编译错误
B.0
C.1
D.运行成功,但不输出
B.
C.
D.
第11题:
public class Foo { public static void main (String []args) { int i = 1; int j = i++; if ((i>++j) && (i++ ==j)) { i +=j; } } } What is the final value of i?()
第12题:
0
1
2
Compilation fails.
第13题:
下面程序段的输出结果是 public class Test { public static void main(String args[]){ int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=l;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
A.37
B.31
C.33
D.35
第14题:
下列程序的执行结果是 ( ) 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.运行成功,但不输出
第15题:
下列程序的输出的结果是( )。 #include<iostream.h> void main() { int i,k,a[10],p[3]; k=5; for (i=0;i<9;i++)a[i]=i; for(i=0;i<3;i++)p[i]=a[i*(i+1)]; for(i=0;i<3;i++)k+=p[i]*2; cout<<k; }
A.20
B.21
C.22
D.23
第16题:
下面代码的运行结果是 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
第17题:
下列程序的执行结果是 ( ) public class ex68{ public static void main(String[]args){ ex68 obj=new ex68(); int s=0; for(int i=1;i<=4;i++){ s+=obj.method(i); } System.out.println(s); } public int method(int n){ if(n==1) return 1; else return n*method(n-1); } }
A.3
B.9
C.33
D.153
第18题:
下述程序的输出结果是( )。 #include<stdio.h> void main() {int a[20],*p[4]; int i,k=0; for(i=0;i<20;i++) a[i]=i; for(i=0;i<4;i++) p[i]=&a[i*i+1]; for(i=0;i<4;i++) {k=k+*p[i];} printf("%d",k); }
A.10
B.18
C.6
D.数组元素引用不合法,输出结果不定
第19题:
下列程序输出结果为( )。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
第20题:
下面程序段的输出结果是( )。 public class TeSt{ public static voidmain(Stringargs[]){ int[]a=new int[11]; int[]p=new int[4]; intk=5; for(int i=1;i<=10;i++) a[i]=i; for(inti=1;i<=3;i++) p[i]=a[i*i]; for(inti=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
A.37
B.31
C.33
D.35
第21题:
以下程序的输出的结果是( )。 #include<iostream.h> void main( ) { int i,k,a[10],p[3]; k=5; for(i=0;i<10;i++) a[i]=i; for(i=0;i<3 ;i++) p[i]=a[i*(i+1)]; for(i=0;i<3;i++) k+=p[i]*2; cout<<k; }
A.20
B.21
C.22
D.23
第22题:
下面程序段的输出结果是( )。 public class Test( public static void main(String args[]){ int[]a=new int[113; int[]p=new int[43; int k=5: for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
A.37
B.31
C.33
D.35
第23题:
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()
第24题:
1
2
3
4
5