tags:

views:

70

answers:

3

Possible Duplicate:
Java Interfaces?

What is the use of interface in java? Is interface helps to provide multiple inheritance actually?

+2  A: 

Interfaces are used as a contract.

If an Object implements an interface, it is guaranteed to offer the functionality specified in the interface.

Interfaces also allow you to treat Objects (that implement the interface) polymorphicly.

Justin Niessner
A: 

What is the purpose of interfaces?

Cristian
A: 

No, multiple inheritance is when you extend behaviours from more than an object.

Interfaces provide a safe way to declare what an object is able to do, not how it does it. That's why you can implement multiple interfaces.

They are used in many kinds of problems, for example when you want to give to your object the same capability that is orthogonal to what these object actually are: for example the interface Comparable states that object can be compared with other objects of the same type. This doesn't relate with what kind of object it is at all.

Jack
"Multiple inheritance of interface" vs "multiple inheritance of implementation" is usually how it is termed.
Tom Hawtin - tackline