What will be the output of the following code snippet?
public class Main { public static void main(String[] args) { int a = 1; int[] myArray = new int[10]; int b = myArray[a]; int c = b + a; System.out.println(b = c); } }
Select 1 option
Correct Option is : B
All the elements of an array of primitives are automatically initialized by default values, which is 0 for numeric types and false for boolean.
Therefore, myArray[1] is 0.
= is not same as ==.
The statement b = c assigns c (whose value is 1) to b. which is then printed.