What will the following program print?
public class Main{ public static void main (String [] args){ String str = "111"; boolean[] myArray = new boolean [1]; if ( myArray [0] ) str = "222"; System.out.println (str); } }
Select 1 option
Correct Option is : A
All the arrays are initialized to contain the default values of their type.
int[] myArray = new int[10]; will contain 10 integers with a value of 0.
Object[] oA = new Object[10]; will contain 10 object references pointing to null.
boolean[] myArray = new boolean[10] will contain 10 booleans of value false.
myArray[0] is false, the if condition fails and str remains 111.