I'm sorry, but if you "know the concept of abstract class", then you know how it "is different from the normal class".
Maybe we should begin with you stating what you believe to be "the concept of abstract class", and what you believe to be "the normal class". Then we can continue on.
The most basic difference, of course, is that you cannot instantiate the abstract class, directly. That does not mean that you cannot get an instatiated object declared as an abstract type, but you cannot directly instantiate the abstract class (except anonymously, in which case it is still not really a direct instantiation of the abstract class as it will be "extended" inline, i.e. the methods are defined on instantiation).
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
his "concept of the abstract class" is flawed if he believes it's what lies at the heart of interfaces...
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
There is actually a significant difference between the abstract class and the interface. The abstract class depends on inheritance, while there is no inheritance in implementing an interface.
An interface simply says "I can do these things". It is a promise to the compiler that a method that implements this interface will have a certain set of methods, which take certain parameters and return certain types. It says nothing about how those methods should be implemented. You might have a "sortable" interface which requires that something sort itself. When you go to implement this method, you get to and you have to implement it each time - this is good because it can be anything at all, and there's no guarantee that sorting your Car class will be anything like sorting your Fencepost class. So this doesn't require anything but "the stuff in this class will be in order when we're done".
This is a drag, if you have a lot of things that are the same, and you want them to sort themselves the same way. Suppose you have a VWBug class and a Miata class and an Edsel class. All of these will be sorted in the same way, presumably - perhaps by VIN or license plate number, or I don't know what, but they'll all sort in the same fashion. So here's where you use an abstract class. You make a class Car, which is abstract - it exists only to be extended - but it extends "Sortable" and it has a fully implemented sort() method, which is suitable for any class extending Car. Now, when you extend Car, you get the sorting for free, and you're automatically registered as implementing Sortable.
Understanding inheritance and interfaces is very important to making Java work for you. I sugest you do some reading on this, and then write little programs to test what you read, until you get the hang of it. Just reading what we all say about here will not be enough to understand it.
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187