This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About interface and abstract classes

 
Ja King
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find both your statements contradictory.
Would you care to rephrase your question?
 
Frank Kellinghusen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vijai ganesh wrote:I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..


When you create an interface, you're defining a contract for what a class can do, without saying how the class will do it. It is up the the developer implementing the interface, how the class runs internally.

When you define an abstract class, you still defining a contract, but you can implement the class partially. When you know that some methods will be the same for all subtypes, you can provide those in your abstract class.

And finally, classes can implement many interfaces, but only can extend one class.

 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the question 4,5 & 6 . I hope this would help
Abstract class and interface
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic