Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what s the difference between abstract class and interface?

 
pinakin raval
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between abstract class and interface?
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interface provides a contract that all implementing classes must meet. If a class is declared to implement an interface, then it must provide an implementation for each method defined in the interface.

An abstract class is similar in that it may declare abstract methods whose implementation is defered to child class(es). An abstract class cannot be instantiated. Sometimes it is useful to use abstract classes becausem unlike interfaces, you can include method implementations for no abstract methods that will be common to all child classes (assuming you don't override them).
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JiG(Beginner).
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://faq.javaranch.com/view?InterfaceVsAbstractClass
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic