Originally posted by JPraveen Kumar:
Tx Tom, I think the other four options can be dumped outright but am still unclear abt how the first option is correct. How do u say that its an anonymous class and not an anonymous interface. Let me generalize it by this code. Hope you can explain it in context of the question :
interface inter{}
public class cls {
public static void main(String args[])
{
inter i = new inter(){};
System.out.println (i.getClass()); //Prints class lib.cls$1
}
}
Now what is i? Is it an anonymous cls class which has an inner implementation of inter? Did the implementation come automatically because of the declaration of type inter? Why should this be allowed as anonymous classes cannot extend or implement and when the class cls by itself has nothing todo with the interface inter.
To confuse me further I changed inter to
interface inter{void k();}
The error is
<anonymous lib.cls$1> is not abstract and does not override abstract method k() in lib.inter
Can u please tell me wht is happening here?
Tx JPK
MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
Don't get me started about those stupid light bulbs. |