When we assign
Object[] ref=new int[]{1,2,3};
the compiler complains
That's because int is not a subtype of Object, int.class.getSuperclass() returns null. Remember that in Java, primitive values (ints, longs, doubles, ...) are not objects.
So it seems that two dimensional arrays extend Object[].
But when I print its superclass name:
System.out.println(ref2.getClass().getSuperclass().getName());
I got java.lang.Object.
Arrays are more like interfaces, as they do multiple inheritance. But they are no real interfaces, in the sense of a Java interface.
class A {}
interface I {}
class B extends A implements I {}
B[][] bArray = new B[1][1];
System.out.println(bArray instanceof A[][]);
System.out.println(bArray instanceof I[][]);
System.out.println(bArray instanceof Object[]);
System.out.println(bArray.getClass().getSuperclass());
for (Class i: bArray.getClass().getInterfaces())
System.out.println(i);
System.out.println(I[][].class.isAssignableFrom(bArray.getClass()));
System.out.println(I[][].class.isInstance(bArray));
Output:
true
true
true
class java.lang.Object
interface java.lang.Cloneable
interface java.io.Serializable
true
true
Furthermore, Java violates the Liskov substitution principle, because
B[] bArray = new B[1];
A[] aArray = bArray;
// bArray[0] = new A(); // causes a compile error
aArray[0] = new A(); // compiles, but causes runtime exception