Jump to content
jimfog

Interface in Java

Recommended Posts

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...