The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Object class and Interface

Posted by Kishori Sharan on May 31, 2001 at 3:02 PM

Runnable r = 0 ;
YOu are trying to assign an object of Object class to Runnable object. This is not allowed. YOU can assign any object or interface object to an object of Object class, but to do reverse you need explicit cast.
Rules:
1) Any interface e.g. Runnable can be assigned to Object
2)Any object of descendant class can be assigned to object of ancestor class. In your case the class "a" is considered to be descendant of Object as well as Runnable and that is why
Runnable r=a1

Thnaks
Kishori




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us