Your first difference is rite. But the basic difference between an interface and abstact class is in the definition. Interface is an agrement between two layers to follow a predifined chanel of communication(I know these are complex words, but this is how a definition is..), and abstarct class is just an abstarct form of a class.
Anways, as per the implementation point of view - your first difference is very well rite, - the second difference is the miltiple inheritance, the way java provides multiple inheritence.
Thank you everyone. I, in fact, learned something new from each of your post. It summarizes all the stuffs that I read about abstract and imterface where later confused myself
Howewver, if any of you think of something else that are related to the differences between Abstract and Interface class please go on. I might know some of them but it is always better to hear from different perspectives.
Originally posted by Kay Liew: [QB]But why A is wrong .. ?
A class must "implement" and interface. (not extend it). Here attempting to extend an interface in a class causes a compile error.
A class (whether abstract or concrete) can extend another class (whether concrete or abstract) but it cannot "implement" that other class.
A class (whether abstract or concrete) can implement an interface, but it can't extend it.
An interface can extend another interface, but it can't implement it.
An interface can't extend or implement a concrete class and it can't extend or implement an abstract class.
The two interface methods in your code are implicitly public so any abstract or concrete class that implements one of the methods has to declare that method as public. (All methods in an interface are public, even if you don't specify them as public in an interface).
Also, an abstract class that implements an interface doesn't have to implement ANY of the interface methods. So an abstract class that implements only one (or both, or none) of the two methods is perfectly legal.
One more point. If an interface has something like int a =3;
The variable a is implicitly public static and final, even though you don't need to specify these modifiers.
Joined: Dec 26, 2003
Louie van Bommel ,
I am glad that you've responded to this thread. I am englightened :roll: