Java数组测试题2018.3.23

本文包含多个关于Java数组的选择题及答案,涉及数组的声明、初始化、操作以及相关语法,适合初学者巩固基础。
摘要由CSDN通过智能技术生成

.选择题

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. }

请选出正确的选项?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值