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 Interface And abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface And abstract" Watch "Interface And abstract" New topic

Interface And abstract

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635

When we have abstract,Why do we ue interface?

By abstract we have variable,But in interface we have not(other than variable that has constant value)

What is difference of the abstract usage and interface usage?
When do we need to interface?
marc weber

Joined: Aug 31, 2004
Posts: 11343

See Interface vs. Abstract Class (linked to from our Beginners FAQ).

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

hint - how many classes can you extend from?

how many interfaces can you implement?

This is not the only, definitive answer, but it's a pretty good one.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I've wondered about that FAQ. Is this statement: Actually the first point is the reason for the existence of interfaces in Java: to provide a form of multiple inheritance. supported in Sun literature?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46405
Stan, in the original white paper about the Java language, look at �2.2.5 about multiple inheritance.
I agree. Here's the link:
subject: Interface And abstract
It's not a secret anymore!