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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java" Watch "Java" New topic
Author

Java

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
Greenhorn

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()
{
}.....melt!!!

abstract Taste taste();
}
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

shantanu,

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: http://aspose.com/file-tools
 
subject: Java
 
Similar Threads
When and how to customize the ActionServlet
CHEECKY but i need help FAST please!
Re: Serializable
what is the use of Serialization in java?
Where to use abstract class and Interface?