Results 1 to 2 of 2
  1. #1
    maa11235 is offline Member
    Join Date
    Dec 2007
    Rep Power

    Default Abstract Class question

    If it is true that one can not instantiate an object from an abstract class, why is it that classes like AbstractCollection have a constructor?


  2. #2
    tim's Avatar
    tim is offline Senior Member
    Join Date
    Dec 2007
    Rep Power

    Default Abstract classes

    Hello maa11235

    It is true that abstract classes cannot be instanced. They are used as a structure to extend from. Abstract classes can contain variables and non-abstract methods. The constructor is used to call the required methods, whether they are abstract or not, and initialize any variables. The reason that an abstract class can have a constructor is so that it's subclass can call that constructor by using the super(<arguments here>) constructor. This style of programming can significantly shorten your code.

    Hope that helped. ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

Similar Threads

  1. Can this be done using abstract class??
    By romina in forum New To Java
    Replies: 6
    Last Post: 03-02-2009, 01:46 PM
  2. Interface Vs Abstract Class
    By javarishi in forum New To Java
    Replies: 5
    Last Post: 06-15-2008, 06:43 AM
  3. Replies: 0
    Last Post: 04-02-2008, 08:04 AM
  4. Abstract Class
    By gapper in forum New To Java
    Replies: 4
    Last Post: 01-31-2008, 02:25 PM
  5. question about abstract methods
    By osval in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts