This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Real Time Scenerio for abstract class and interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Real Time Scenerio for abstract class and interface" Watch "Real Time Scenerio for abstract class and interface" New topic
Author

Real Time Scenerio for abstract class and interface

Giri moh'kar
Greenhorn

Joined: Jun 11, 2007
Posts: 7
when do we use abstract class and interface?do we have any real time example?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I'm guessing you don't really mean real time.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

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

Joined: Jun 11, 2007
Posts: 7
Thanks Kaydell Leavitt..
 
jQuery in Action, 2nd edition
 
subject: Real Time Scenerio for abstract class and interface
 
Similar Threads
can and any one this abstract and interface
which senario we use abstract and interface in java
When to go for abstract class and interface
Interface vs abstract class
Abstract class and interface