Question 20

The statements string var1[ ];

The statements string var1[ ]; var1 = new string[3]; system.out.println (var1[1]); print
  1. AAn empty string
  2. BNull
  3. C0
  4. DA garbage character
Show answerHide answer

Correct answer: (B) Null

Explanation

new String[3] creates an array of references, and each element starts with the default value null. So printing var1[1] prints null.

From DSSSB TGT Computer Science Practice Set 3

This is question 20 of DSSSB TGT Computer Science Practice Set 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.