0

Possible Duplicate:
Java Interfaces?

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

Community
  • 1
  • 1
shin
  • 1,675
  • 4
  • 22
  • 46
  • 4
    You're more likely to get answers if you go back and accept the best answers of your previous questions. – crazyscot Jun 09 '10 at 12:57
  • 1
    You've asked six questions but haven't accepted the answers to any of them. You may want to go back and accept answers to previous questions (by clicking the check mark next to the answer that helped) to get better responses on future questions. – VoteyDisciple Jun 09 '10 at 12:57

2 Answers2

2

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
  • 242,243
  • 40
  • 408
  • 536
0

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
  • 131,802
  • 30
  • 241
  • 343