|
Solution 1: The program will not show any compile errors and there will be no
warnings either. But when we try to run the program , the program runs fine ,
giving an exception. The length of integer array is not defined , so it will
take the length of array with the number of elements on initialization. The
program runs till intCounter is 4 , and then throw the exception. The
output of the program will be :
|
Array Element[0 ]:1
Array Element[1 ]:2
Array Element[2 ]:3
Array Element[3 ]:4
Array Element[4 ]:5
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at
iknowjava.arrayQz1.main(arrayQz1.java:15)
|
|
|
|
Solution To question2 :
|
|
There are a compile time errors since the array is of type int , and we are
assigning a double value to the integer array
|
|
|
|
Question 3: |
|
This is again a compile time error , since 10.2 is float type value.
|
|
|
|
Question 4:
|
|
The program gives the highest number in the array. The array bigArray is never
used , and hence a warning.
|
|
|
|
|
|
|