0
1
2
4
6
第1题:
以下程序的输出结果是( )。 #include<iostream.h> void main() { int a(5),b(6),i(0),j(0); switch(a) { case 5:switch(b) { case 5:i++;break; case 6:j++;break; default:i++;j++; } case 6:i++; j++; break; default:i++;j++; } cout<<i<<","<<j<<endl; }
A.1,2
B.1,3
C.2,2
D.2,3
第2题:
A.0
B.1
C.2
D.4
E.6
第3题:
下面程序的运行结果是( )。 define P(A)printf("%d",A)main() {int j,a[]={1,2,3,4,5,6,7},i=5; for(j=3;j>1;j--) {switch(j) {case 1: case 2:P(a[i++]);break; case 3:P(a[--i]); } } }
第4题:
下列程序的输出的结果是______。 public class exl6 { public static void main(String[] args) { int j=10; for(int i=0;i<3;i++) { j-=i+1; switch (j){ case 3: break; case 5: break; case 8: break; default: j=0;break; } } System,out.println(j); } }
A.5
B.3
C.8
D.0
第5题:
以下程序的输出结果为( )。 public class Main { public static void main(String[] args) { int i=0, j=0, a=6; if((++i>0)||(++j>0)) a++; System.out.println( "i=" +i+", j ="+j+", a="+A; } }
A.i=0, j=0, a=6
B.i=1, j=1, a=7
C.i=1, j=0, a=7
D.i=0, j=1, a=7
第6题:
下列程序的输出结果是 ( ) main( ) { int i,j,m=0,n=0; for(i=0;i<2;i+ +) for(j=0;j<2;j+ +) if(j>=i) m=1; n+ +; printf("%d\n",n); }
A.4
B.2
C.1
D.0
第7题:
下列程序的输出结果是( )。
#include<stdio.h>
main
{ int a=0,i;
for(i=1;i<5;i++)
{ switch(i)
{ case 0:
case 3:a+=1;
case 1;
case 2:a+=2;
default:a+=3;
}
}
printf("%d",a);
}
A.19
B.1
C.6
D.8
第8题:
int I=1, j=0 switch(i) { case 2: j+=6; case 4: j+=1; default: j +=2; case 0: j +=4; } What is the value of j at line 16?()
第9题:
int i = 1,j = -1; switch (i) { case 0, 1:j = 1; case 2: j = 2; default; j = 0; } System.out.println(“j=”+j); What is the result?()
第10题:
1. int I=1, j=0 2. 3. switch(i) { 4. case 2: 5. j+=6; 6. 7. case 4: 8. j+=1; 9. 10. default: 11. j +=2; 12. 13. case 0: 14. j +=4; 15. } 16. What is the value of j at line 16?()
第11题:
The program runs and prints “i=1, j=0”
The program runs and prints “i=1, j=4”
The program runs and prints “i=3, j=4”
The program runs and prints “i=3, j=0”
An error at line 4 causes compilation to fail.
An error at line 7 causes compilation to fail.
第12题:
0
3
4
5
The code will not compile.
第13题:
A.0
B.2
C.4
D.6
E.9
F.13
第14题:
下列语句序列执行后,j的值是( )。 int j=0; for (int i=3 i>0; i- -)j+=i;
A.3
B.4
C.6
D.5
第15题:
有以下程序: void sort(int a[],int n) { int i,j,t; for(i=0;i<n-1;i+=2) for(j=i+2; j<n;j+=2) if(a[i]<a [j]){t=a[i];a[i]=a[j];a[j]=t;} } main( ) { int aa[10]=(1,2,3,4,5,6,7,8,9,10),i; sort(aa,10); for(i=0;i<10;i++) printf("%d",aa[i]); printf("\n"); } 其输出结果是 ______。
A.1,2,3,4,5,6,7,8,9,10,
B.10,9,8,7,6,5,4,3,2.,1,
C.9,2,7,4,5,6,3,8,1,10,
D.1,10,3,8,5,6,7,4,9,2,
第16题:
下列程序的输出结果是【 】。
include<iostream.h>
void main()
{
inta(5),b(6),i(0)1j(0);
switch(a)
{
case 5:switch(b)
{
case 5:i++;break;
case 6:j++;break;
defaun:i++;j++;
}
case 6:i++;
j++;
break;
default:i++;j++;
}
cout<<i<<","<<j<<endl;
}
第17题:
下列程序的输出结果是( )。 #include<stdio.h> main { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=1; case 1; case 2:a+=2; default:a+=3; } } printf("%d",a); }
A.19
B.1
C.6
D.8
第18题:
有以下程序: #include <stdio.h> void sort(int a[],int n) { int i,j,t; for(i=0;i<n-1;i+=2) for(j=i+2;j<n;j+=2) if(a[i]<a[j]){t=a[i];a[i]=a[j];a[j]=t;} } main() { int aa[10]={1,2,3,4,5,6,7,8,9,10},i; sort(aa,10); for(i=0;i<10;i++) printf("%d.",aa[i]); printf("\n"); } 其输出结果是( )。
A.1,2,3,4,5,6,7,8,9,10,
B.10,9,8,7,6,5,4,3,2,1,
C.9,2,7,4,5,6,3,8,1,10,
D.1,10,3,8,5,6,7,4,9,2,
第19题:
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?()
第20题:
public class Test { public static void main(String Args[]) { int i =1, j = 0; switch(i) { case 2: j +=6; case 4: j +=1; default: j +=2; case 0: j +=4; } System.out.println(“j =” +j); } } What is the result? ()
第21题:
1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()
第22题:
j = -1
j = 0
j = 1
j = 2
Compilation fails.
第23题:
Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8
第24题:
0
2
4
6
9
13