下面代码的运行结果是( )。public class Person {static int arr[] = new int [10];public static void main(String args[]) {System.out.println(arr[9]);}}
A. 编译错误
B. 编译正确,运行时产生错误
C. 输出0
D. 输出 空
查看答案
以下输出是什么classTestIt{publicstaticvoidmain(String[]args){int[]myArray={1,2,3,4,5};ChangeIt.doIt(myArray);for(intj=0;j
A. 12345
B. 什么都不会打印出来
C. 程序将因运行时错误而停止
D. 00000
以下输出是什么 ?class LowHighSwap{static void doIt( int[] z ){int temp = z[z.length-1];z[z.length-1] = z[0];z[0] = temp;}}class TestIt{public static void main( String[] args ){int[] myArray = {1, 2, 3, 4, 5};LowHighSwap.doIt(myArray);for (int i = 0; i < myArray.length; i++){System.out.print(myArray[i] + " ");}}}
A. 1 2 3 4 5
B. 5 2 3 4 1
C. 1 2 3 4 1
D. 5 2 3 4 5
声明一个数组 :int [] ar = {1,2,3,4,5};ar[4]的值是多少?
A. 2
B. 3
C. 4
D. 5
声明:int [] ar = {1,2,3,4,5,6};数组ar.length的值是多少?
A. 0
B. 5
C. 6
D. 7