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 Interface and Abstract class 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 "Interface and Abstract class" Watch "Interface and Abstract class" New topic

Interface and Abstract class

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
Can you explain me when to use the interface and when to use the Abstract Class?

bksella sella
Ranch Hand

Joined: Jul 31, 2003
Posts: 32
Hi Abhishek,

You will use an Interface when you want the developer to implement his own method implementations, but to have the same method signature.

You will use an Abstract class when you have some common implementation for certain methods and let the developer implement his own logic for the other methods which are declared abstract.

I hope you understood. Let me know if this is clear.

- Sella
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
This is a *very* frequently asked question. If you search this and the beginners forum, you should get tons of threads that discuss this topic.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
It is sorta covered in the JavaRanch Style Guide.
subject: Interface and Abstract class
Similar Threads
use of abstact class and interface
When to use Interfcae and abstract class
Abstract Class & Interface
abstract class vs interface ?
forcing implementing methods