Hi Alex,

While interfaces and abstract classes may seem similar superficially
(they both are not instantiable), they serve different purposes and
have different use cases.

This page provides a simple and quick overview of the differences:
http://mindprod.com/jgloss/interfacevsabstract.html

Among other things, that pages points out that an interface generally
describes abilities (what a class can do), while an abstract class
defines a core identity (what a class is).

As a general example, lets take the ability to walk.  If we were doing
a class hierarchy for a bunch of objects that can walk, we could make
a base object that can walk.  We could call it a Walker.  But what is
a Walker?  It's not really an object it is? We could have a marsupial,
a human, a robot, and an alien and all of them can walk.  Walking is
not an "object" with properties, it's an ability.  So instead of
defining a base class with a method for walking from which all things
that can walk  would inherit, we define an interface that can be added
to any object to give it the ability to walk.

An example of a specific implementation is found in the "runnable"
interface.  We can take any object and make it "thread capable" by
having it implement a thread interface.  While the same thing could be
accomplished by inheriting from the class Thread, its not the ideal
way of doing it because normally you subclass an object to implement a
new kind of that object with distinct features.

I hope my explanation was helpful.  But also see the page I referenced
above.  It goes into more detail and gives more examples.

On Tue, Jul 14, 2009 at 09:02, Alex<[email protected]> wrote:
>
> Dear Java Programmer:
>
> For an interface not to be directly constructed as an object is
> understandable.  Although, the interface is subfamily of abstract class.
> What is the point of having this abstract class which is like an interface
> with method signatures with partial implementation?  Not too understanding
> about this detail?  Please comment.
>
>
>
> JKid
> --- On Tue, 7/14/09, Georgiana Lungu <[email protected]> wrote:
>
> From: Georgiana Lungu <[email protected]>
> Subject: [java programming] Re: subclassed?
> To: "Free Java Programming Online Training Course By Sang Shin"
> <[email protected]>
> Date: Tuesday, July 14, 2009, 3:33 AM
>
>
> They can do what ever you program them to do, is just that you can not
> create an object with it directly.
>
> On Jul 13, 12:38 pm, Maurizio Marrocco <[email protected]>
> wrote:
>> Hello,
>> I have a doubt regarding the constructors of an abstact class. Do they do
>> something or they only call the constructors of its superclass?
>>
>> Regards,
>> Maurizio Marrocco
>>
>> On Mon, Jul 13, 2009 at 10:26 AM, Georgiana
>>
>>
>>
>> Lungu<[email protected]> wrote:
>>
>> > Well, first of all, running the constructor of a subclass calls the
>> > constructors of its parents, so creating an instance of a subclass
>> > makes the constructor of the abstract class run. Secondly, if you have
>> > any variable that refers to the type of the inherriting subclass, it
>> > still passes the is-a test for the tyep of the abstract parent class,
>> > so it is, implicitly an object of that type and you can use it to call
>> > abstract classs' methods and fields.- Hide quoted text -
>>
>> - Show quoted text -
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to