Saturday 21 January 2012

Java puzzler: Initiating array of integer to object reference

Can you tell whether the following code will compile or not?

Object o = new int[10];

The answer to this is yes....because Arrays are object only....and super class of an array is java.lang.Object class.

No comments:

Post a Comment