File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Empty abstract classs vs Empty 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 » Beginning Java
Bookmark "Empty abstract classs vs Empty interface" Watch "Empty abstract classs vs Empty interface" New topic

Empty abstract classs vs Empty interface

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
whats a difference between an empty abstract classs and an empty interface?

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11150

In a single class, you can implement as many interfaces as you want, but you can only inherit from one abstract class.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
A friend of mine was asked this question and she replied the same as you mentioned. But he wasnt satisfied. So is there more to it than just one explanation.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Who wasn't satisfied? Your friend is "she" so this "he" is a third person. Seems to me that's the person you should be asking.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Well, an empty interface has a special name (a "marker interface"), and the JDK contains a number of examples of how they used to be used, back before annotations were introduced in Java5. An empty abstract class -- well, that's just dumb

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Empty abstract classs vs Empty interface
Similar Threads
What is the difference between an empty interface and an empty abstract class ?
abstract class and interface
abstract class and Interface
Abstract class and Interface
Abstract & Interface