File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Abstract & Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract & Interface " Watch "Abstract & Interface " New topic

Abstract & Interface

Siva kandasamy
Ranch Hand

Joined: Dec 31, 2002
Posts: 139
I am new this forum and new to Java.
In this forum, many explained the difference between the abstract and interfaces.
Does any one knows, what is the driver behind these two architecture which looks
pretty similar.
I mean, Why interfaces ?
What is that we can't achieve by having abstract class, we needed interface vice versa ?
Eric Fletcher
Ranch Hand

Joined: Oct 26, 2000
Posts: 188
Check out this article, it helped answer this question for me when I read it awhile back.
designing with interfaces

My theory of evolution is that Darwin was adopted. - Steven Wright
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Interfaces provide the ability to have multiple inheritance.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Expanding a bit more: The C++ language allowed a more powerful form of multiple inheritance, and the Java language designers felt that this caused problems more often than it solved them. They felt that multiple inheritance of method declarations was a good thing, but multiple inheritance of method implementations was bad. So you can inherit as many declarations as you want, if they're defined in interfaces - but you can only directly inherit from one class. This inherited class may be an abstract class if there's at least some implementation which you wish to inherit, but if it doesn't make sense to provide a complete implementation (usually because you need the flexibility to implement some things differently in different classes, and there's no single "default behavior" for every method that makes sense to put in a base class).
Definitely check out the JavaWorld article Eric cited for more info.
[ December 31, 2002: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Siva kandasamy
Ranch Hand

Joined: Dec 31, 2002
Posts: 139
Thanks & Happy New Year.
I agree. Here's the link:
subject: Abstract & Interface
It's not a secret anymore!