Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-17-2007, 03:44 AM
Member
 
Join Date: Dec 2007
Posts: 4
maa11235 is on a distinguished road
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?

maa11235
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-05-2008, 11:30 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
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.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface Vs Abstract Class javarishi New To Java 5 06-15-2008 06:43 AM
what is the Priority for execution of Interface class and a Abstract class Santoshbk Advanced Java 0 04-02-2008 08:04 AM
Abstract Class gapper New To Java 4 01-31-2008 02:25 PM
Can this be done using abstract class?? romina New To Java 2 07-26-2007 10:09 AM
question about abstract methods osval New To Java 1 07-25-2007 09:36 PM


All times are GMT +3. The time now is 06:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org