aspose file tools*
The moose likes Beginning Java and the fly likes interface&classes casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "interface&classes casting" Watch "interface&classes casting" New topic
Author

interface&classes casting

PUNNU GULATI
Greenhorn

Joined: Feb 19, 2001
Posts: 6
hi everyone.
i am doing prepation for jcp
a INTERFACE bINTERFACE
|
|
CLASS B IMPLEMENTS A
HERE NO RELATION BETWEEN A INTER AND B INTER
IF IN A PROGRAM
WE WRITE
b obj1;
B obj=(B)obj1;
in this case there is no cmpile time error why
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi,
You get no compile error because you are using casting. When you perform casting you are telling the compiler that you know what you are doing and to stop checking if I am right!
You will still get a run time error if the Object can't be cast to the interface!
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface&classes casting