File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes what is super? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is super?" Watch "what is super?" New topic

what is super?

scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
Hi all, I'm waiting for amazon to deliver the books... meanwhile, I have a java project to create!
Here is some code I found for a database access bean. Can someone please explain what the super() call does and why there is a method in the class with the same name as the class? Is that a requirement in a bean?
muchos thankyous,
Scottie Zman
package sqlBeans;
import java.sql.*;
public class DbBean {
String dbURL;
String dbDriver;
private Connection dbConn;

public DbBean(){

public boolean connect() throws ClassNotFoundException,SQLException {
dbConn = DriverManager.getConnection(dbURL);
return true;

public void close() throws SQLException{

public ResultSet execSQL(String strSQL) throws SQLException{
Statement stmt = dbConn.createStatement();
ResultSet rs = stmt.executeQuery(strSQL);
return (rs == null) ? null : rs;

public int updateSQL(String strSQL) throws SQLException{
Statement stmt = dbConn.createStatement();
int r = stmt.executeUpdate(strSQL);
return (r == 0) ? 0 : r;

[This message has been edited by scottie zman (edited August 23, 2001).]
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
There is no good reason for the super() call to be used like that. It would be automatically called if you left it out. Even then it doesn't do much. super(arguments) calls a contructor on a parent class. In this case that class would be java.lang.Object. Here is an example of it's use:
scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
Thanks for the explanation and example, it helped a lot!
I agree. Here's the link:
subject: what is super?
It's not a secret anymore!