This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: interface&classes casting