Question 141

What is the output of the Java code? int[] a = new int[3];

What is the output of the Java code? int[] a = new int[3]; System.out.println(a[1]);
  1. A0
  2. Bnull
  3. CGarbage value
  4. DCompile error
Show answerHide answer

Correct answer: (A) 0

Explanation

Java arrays of int are initialised to 0.

From DSSSB TGT Computer Science Full Mock Test 4

This is question 141 of DSSSB TGT Computer Science Full Mock Test 4. 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.