• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface&classes casting

 
PUNNU GULATI
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic