Java OCA OCP Practice Question 1235

Question

What is the output of the following program?

public class Main {
   public static void main(String args[]) {
      Object[] o = new Object[2];
      byte[] b = new byte[2];
      System.out.print(o[0]);
      System.out.println(b[1]);
   }

}
  • A. 0
  • B. o0
  • C. A NullPointerException is thrown
  • D. null0


D.

Note

The default value of an Object is null and the default value of a byte is 0.




PreviousNext

Related