A-A+

阅读下列代码 publicclassPerson{ staticintalt[]=newin

2022-08-06 05:44:44 问答库 阅读 176 次

问题详情

阅读下列代码 publicclassPerson{ staticintalt[]=newint[[10]; public static voidmain(Stringargs){ System.out.println{all[9]); } } 该代码的运行结果是()。
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出零
D.输出空请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:C
解析:arr[]为整[]型数组,分配地址后默认值为0,所以创建数组时也是对每个数组元素赋初值0。

考点:代码