It's not a secret anymore!
The moose likes Beginning Java and the fly likes Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java" Watch "Java" New topic


Shantanu Puranik
Ranch Hand

Joined: Jun 10, 2004
Posts: 67
In Which situation we should choose Abstract and in which situation we should use Interface

--- Shantanu
Shraddha Jain

Joined: Feb 02, 2006
Posts: 27
if there's something u want every subclass to do exactly the same way and there are things u cannot generalize u can go for an abstract class
take IceCream for instance
it could be of many flavors - vanilla,choclate, coffee, butterscotch.........
so they all will taste() differently depending on their flavor,
but when u say melt() they simply have to ...well melt!!
so in this case u could use an Abstract class Icecream:

abstract class IceCream{
public void melt()

abstract Taste taste();
Ben Souther

Joined: Dec 11, 2004
Posts: 13410


This forum is for Servlet related questions.
Moving to Java In General (Beginner).

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Java
It's not a secret anymore!