Jump to content

Interface in Java


jimfog
 Share

Recommended Posts

What exactly happens when a class implements an interface? I am a little confused with this.

Link to comment
Share on other sites

interface contains methods without body. if any class implements a interface it must define the body. interface gives consistency between classes who uses them. oppose to multiple inheritance language like c++, java is single inheritance language. here in java interface gives classes to use and share multiple behavior among different classes.

Link to comment
Share on other sites

An interface allows multiple independent classes to be used in the same way. The interface tells the class the name of the methods it has to implement, but each class can implement the methods however suits it best.

Link to comment
Share on other sites

  • 2 weeks later...
http://docs.oracle.c.../interface.html since classes define the state and behavior of objects (like a blueprint), think of an interface as a class that is the blueprint for another class. Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...