What will be the result of trying to compile and execute of the following program?
public class Main{ public static void main (String args [] ){ int i = 0 ; int [] myArray = {10, 20} ; myArray [i] = i = 30 ; System.out.println (""+ myArray [ 0 ] + " " + myArray [ 1 ] + " "+i) ; } }
Select 1 option
Correct Option is : D
The statement myArray[i] = i = 30 ; will be processed as follows:
myArray[i] = i = 30; => myArray[0] = i = 30 ; => i = 30; myArray[0] = i ; => myArray[0] = 30 ;
First, the dimension expressions are evaluated, left-to-right.
If any of the expression evaluations completes abruptly, the expressions to the right of it are not evaluated.