aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Abstract classes?" Watch "Abstract classes?" New topic
Author

Abstract classes?

rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Could anyone explain this.

Abstract class can have constructors, but an abstract class cannot be insantiated.

Then what is the use of a constructor in an abstract class?

Thanks.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by rengarajan vaikuntam:

Then what is the use of a constructor in an abstract class?


You must have a constructor in an abstract class because an abstract class can be extended. When a subclass is instantiated, the superclass must be initialized prior to the sublcass' initialization. This is because the superclass, which may contain data members, might also include the initialization procedures for those members. If that code was not executed, it's possible that not all subclass members (some of which may be inherited from the abstract class) would be initialized properly.


SCJP Tipline, etc.
rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Thank you corey i got it and it is clear now.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Abstract classes?
 
Similar Threads
A mock question
ABSTRACT
usage of a class
HttpServlet class
A question about container!