Here is the question from K & b book :
import java.util.*;
class Roo{
public static void main(
String args[])
{
Roo r=new Roo();
Object o=r.test();
}
object
test(){}
//line 9
}
Which two of the following code fragments inserted at line 9 will not compile?
1)return null;
2)object t=new object();
return t;
3)int a[]=new int[2];
return a;
4) char[][] c=new char[2][2];
return c[0][1];
5)char [][]c=new char[2][2];
retutn c[1];
6)return 7;
Ans:4 and 6
I know that since 7 is primitive you cann't return. But I didn't understand ans 4 .
What is the difference between 4 & 5;
Can anybody help me to understand?
Thanks.