The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000

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:

Interface Vs. Abstract Class

Posted by Siva Jasthi on November 06, 2000 at 1:07 PM

(1) In the case of abstract class, you know the class hierarchy in advance.
You can only create sub-classes to the abstract class. But you can not make
any existing class (from other branch of the class tree) to implement the abstract
class.

(2) Where as in the case of Interface, you can make ANY class in the hierarchy
to implement the interface. The interfaces are Java Way of providing
the multiple inheritance feature. If a class implements multiple
interfaces, then we are forcing the class to implement different behaviours
defined in the interfaces.

> Hi
> What is the key difference between interface and abstratclass in practical.
> Theoritically abstractclass is partially implemented class where as methods in an interface doesT contain method def.
> My question is practically where can we use interface and where can we use abstract class.
> if any one can explain with an example it would be great

> thanx
> Ramesh






Replies:

Sponsored Links



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