wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes super(); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "super();" Watch "super();" New topic
Author

super();

Kevin Knowles
Ranch Hand

Joined: Dec 29, 2002
Posts: 45

This code would call all of the parents constructors or methods. Is that correct?
James Clinton
Ranch Hand

Joined: Jun 23, 2003
Posts: 190
super() will call the conctructor of you extending class. Also if used it must be the first line in a contructor method.
For example:

// PARENT CLASS

// CHILD CLASS


Calling super is only neccessay if you have code in the constructor that needs initialising.
Else you can happy invoke its methods (assuming they are visible (public, protected etc)).
super.someParentMethod();
Hope that helps.
/ James
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
This code would call all of the parents constructors or methods. Is that correct?
No. super() would only invode the superclass constructor that takes no arguments.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: super();
 
Similar Threads
WA #1.....word association
Doubly implementing Interface
Overriding equals()
coreJava
Problem with instance initializer