一.选择题
QUESTION NO: 1
下面哪两项编译会出错? (选择两项)
A. float[] = new float(3);
B. float f2[] = new float[];
C. float[] f1 = new float[3];
D. float f3[] = new float[3];
E. float f5[] = { 1.0f, 2.0f, 2.0f };
F. float f4[] = new float[] { 1.0f. 2.0f. 3.0f};
QUESTION NO: 2
Given:
11. int i=0;int j=0;
12. boolean b=(i++)<(i++) || (j--)>j(--)
13. System.out.println(“i = “ +i+ “and j = “+j+"and b="+b);
请选出正确执行结果?
A. i = 2 and j = -2 and b=false
B. i = 2 and j = -1 and b=true
C. i = 2 and j = 0 and b=false
D. i = 2 and j = 0 and b=true
E. i = 1 and j = 1 and b=true
QUESTION NO: 3
Given:
11. int i = 20,j = 10;
12. for(i=0;i<j;i++)
13. if(i==j) {
14. j++;
15. break;
16. }
17. }
18. System.out.println(“i =” +i+” and j = “+j);
请选出正确执行结果?
A. i = 10 and j = 5
B. i = 10 and j = 11
C. i = 10 and j = 0
D. i = 10 and j = 10
E. i = 9 and j = 11
QUESTION NO: 4
Given:
11. int x = 3;
12. int y = 1;
13. if (x = y) {
14. System.out.println(“x = “ + x);
15. }
下列选项哪些是正确的?
A. x = 1
B. x = 3
C. 编译失败.
D. 没有输出.
E. 在执行时会出异常.
QUESTION NO: 5
Given:
1. public class ArrayTest {
2. public static void main(String[] args) {
3. float f1[], f2[];
4. f1 = new float[10];
5. f2 = f1;
6. System.out.println(“f2[0]= “ + f2[0]);
7. }
8. }
下列选项哪些是正确的?
A. 输出 f2[0] = 0.0
B. 输出 f2[0] = NaN.
C. 在第5行出现错误,编译无法通过
D. 在第6行出现错误,编译无法通过
E. 执行这个类的时候在第6行出现错误.
QUESTION NO: 6
Given:
1. public class Test {
2. public int aMethod() {
3. static int i = 0;
4. i++;
5. return i;
6. }
7. public static void main (String args[]) {
8. Test test = new Test();
9. test.aMethod();
10. int j = test.aMethod();
11. System.out.println(j);
12. }
13. }
请选出正确的选项?