int [] ia1 = {1,2,3};
int [][] ia2;
Object o = ia1;
ia2 = new int [3][3];
ia2[0] = (int[])o;
ia2[0][0] = (int[])o;

Answer is "Compilation fails in last line"

Explanation: Arrays are objects, and that each array dimension is a separate type. So, for instance, ia2 is of type "two dimensional int array", which is a different type than ia1. Last line attempts to assign a one-dimensional array into an int.

Doubt: Isn't the second last line also trying to assign a one dimensional int array to a two dimensional one?
I'm terribly confused in the last two lines only. Rest I understood.

Thanks.

This is not a site where you can market/advertise your stuff suhad12 by posting links irrelevant to the original posted content!!

ia2[0][0] = (int[])o;

here you are trying to store a one dimensional array of ints as single int.

ia2[0] = (int[])o;
here, ia2 is just one array, the one that is found

ia2 is a two dimensional array
ia2[0] is the first element of this two-dimensional array, being an one dimensional array itself
ia2[0][0] is the first element of the previous found one dimensional array, and is just a single int, not an array

commented: Great got it stultuske. Thanks +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.