File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Real Time Scenerio for abstract class and interface

 
Giri moh'kar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when do we use abstract class and interface?do we have any real time example?
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing you don't really mean real time.
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Java Ranch,

I take it that you mean "real-world" instead of "real-time".

A real-world example is a "fruit". We can consider using either an interface or an abstract class. Since all fruits have a common property, weight, an abstract class should be used rather than an interface since interfaces can't contain variables. (Though, you might find a reason to use both an abstract class and interfaces).

Concrete classes of fruit could be "apple", "bannanna", and a "pear".



Kaydell
[ June 11, 2007: Message edited by: Kaydell Leavitt ]
 
Giri moh'kar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kaydell Leavitt..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic