Q.The statements string var1[ ]; var1 = new string[3]; system.out.println (var1[1]); print
Correct answer: null
Explanation
Here's a breakdown to each steps - 1. string var1[ ]; declares an array of strings called var1. 2. var1 = new string [3]; initializes the var1 array with a length of 3. 3. Since the no value assigned to the array elements, they are initialized with their default values, which is null for strings in java. 4. System.out.println(var1[1]), attempts to print the value of the second element of the var1 array. Since the second element of the array is null, the output will be null.
Here's a breakdown to each steps - 1. string var1[ ]; declares an array of strings called var1. 2. var1 = new string [3]; initializes the var1 array with a length of 3. 3. Since the no value assigned to the array elements, they are initialized with their default values, which is null for strings in java. 4. System.out.println(var1[1]), attempts to print the value of the second element of the var1 array. Since the second element of the array is null, the output will be null.