constructor and Abstract class

Hi All,

Say I have an abstract class and subclass that extends this abstract class. As far as I understand the first statement in the subclass constructor has to be super. if the subclass constructor doesn't call a superclass constructor explicity then the default constructor of the superclass is invoked. But what if I don't define any default constructor in the abstract class and I have some other constructor?

Thank u

Eyal

[456 byte] By [Eyal2007a] at [2007-11-27 10:38:24]
# 1

Try it out.

Here is a small example.

abstract class A {

int i;

public A(int i) {

this.i=i;

}

}

abstract class B extends A {

int x;

public B(int i, int x) {

super(i);

this.x =x;

}

}

Try removing super in class B whilst A has explicitly declared a constructor which takes an int arg. Then try removing super from B and the explicit constructor from A.

_helloWorld_a at 2007-7-28 18:54:15 > top of Java-index,Java Essentials,New To Java...
# 2

Got it!!

Thanks!

Eyal2007a at 2007-7-28 18:54:15 > top of Java-index,Java Essentials,New To Java...