57. Given the following code fragment, what will happen
when we try to compile and run the showSmall method?
1. public void printArray( long[] x ){
2. for(int i = 0 ; i < x.length ; i++ ){
3. System.out.println("# " + i + " = " +
x[i] );
4. }
5. }
6. int[] small = { 1,2,3,4,5,6,7,8,9,0 };
7. public void showSmall() {
8. printArray( small );
9. }
Select 1 correct answer:
A. The code compiles and the JVM automatically promotes
the int array to a long array.
B. The compiler complains that there is no method matching
the use in line 8.
C. The code compiles but a runtime ClassCastException
is thrown in line 8.