The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000



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.



Posted by neeraja on February 27, 2001 at 7:42 AM

> 1]A class must have atleast one abstract method in order to make the class an abstract class whereas in an interface all mathods are abstarct by default.

> 2]An abstarct mathod in the abstarct class can have a body whereas no mathod in an interface can have a body.

> 3]All mathods in the interface must be implemented whereas it is not so with an abstarct class.

> 4] Best way to understand both as take an example of mammel & man. Mammel is an abstarct class where certain properties of a man are defined.(Like sound)This sound mathod will not have a body but man class will implement it as man speaks. Dog class will implement it as dog barks.

> Interface whereas just another class that works as a contract between classes.You and your wife live together and your wife does not know how to clean the house(don't mind bare example) so you can't create another relationship as java does not accept multiple relationship.So make a contarct with a maid she knows her job but you / your wife will once tell how you want her to clean your house. Here the maid is an interface.

> Thanks

> Convey me your opinion


Sponsored Links

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