wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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
 
Similar Threads
interface
MasterExam OO question
interfaces used to work on my system but now they dont :)
Regarding Interface Concept
how to work with interface in java?