aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract class constructors 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 class constructors" Watch "abstract class constructors" New topic
Author

abstract class constructors

preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93
Can an abstract class have constructors?

I would have thought no , as they cannot be instantiated , so there is no real purpose... Am I right?
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Yes, an abstract class can have constructors.
An abstract class may have instance variables and non-abstract methods (common to all concrete subclasses) that operate on those variables. A constructor could be used to initialize the instance variables.
A constructor of a concrete subclass would invoke the superclass constructor to initialize the variables of the abstract superclass.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391

Graph is part of a framework. It supplies nearly all of the methods to support a generic graph editor.
SimpleGraph is a client-defined extension that supplies the geometric shapes of the nodes and edges to be used in the graph.

Graph is an abstract class. It needs a constructor to initialize the variables to do its work.

(From Cay Horstmann�s Object Oriented Design & Patterns)
[ May 27, 2003: Message edited by: Marlene Miller ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: abstract class constructors
 
Similar Threads
some doubts
org.hibernate.InstantiationException: Cannot instantiate abstract class or interface
Abstract class
Abstract Class Constructor
Abstract Classes