What is the result of compiling and running the following code?
class ForEach1
...{
public static void main(String args[])
...{
byte arr[]=new byte[]...{2,3,4};
for(final int i : getCharArray(arr))
System.out.print(i);
}
static char[] getCharArray(byte[] arr)
...{
char[] carr=new char[4];
int i=0;
for(byte c : arr)
...{
carr[i]=(char)c++;
i++;
}
return carr;
}
}
choice one answer
A. Code does not compile because variable I is declared final within the for loop
B. Code does not compile because an int variable is used to iterate through a char array
C. Prints 2340
D. Prints 3451
E. None of these
2562

被折叠的 条评论
为什么被折叠?



