给出下面代码:public class Person{static int arr[] = new int[10];public static void main(String a[]) {System.out.println(arr[1]);}}以下那个说法正确?
A. 编译时将产生错误;
B. 编译时正确,运行时将产生错误;
C. 输出0;
D. 输出null。
查看答案
设有如下程序,其调试结果为:
class Q2 {
public static void main(String[] args) {
int[] seeds = {1,2,3,4,6,8};
int n= seeds.length;
for (int i = 0; i< 3; i++)
for (int k = 0; k< n-1; k++)
seeds[k]= seeds[k+1];
for (int i = 0; i
System.out.print("/t"+seeds[i]);
}
}
A. 输出: 1 2 3 4 6
B. 输出: 4 6 8 8 8
C. 输出: 2 3 4 6 8
D. 输出: 2 3 4 6
以下程序的输出结果为:public class example {public static void main(String args[]) {int s=0;for (int i=0;i<5;i++) {for (int j=10;j>3*i;j--)s += i*j;}System.out.println(s);}}
A. 127
B. 136
C. 147
D. 153
以下代码的调试结果?public class Q {public static void main(String argv[]) {int anar[]= new int[5];System.out.println(anar[0]);}}
A. 编译错误:anar 在引用前未初始化。
C. 0
D. 5
以下程序的运行结果为?
class test {
public static void main(String args[]) {
int i,j=0;
for(i=10;i<0;i--) { j++; }
switch(j) {
case (0) : j=j+1;
case (1、 : j=j+2; break;
case (2、: j=j+3; break;
case (10) : j=j+10; break;
default : break;
}
System.out.println(j);
}
}
A. 0
B. 1
C. 2
D. 3
E. 10