Consider the following code:
class ExtendsObject extends Object {
ExtendsObject () {
super("H"); //if this is not used, we get a compile error!!!
//compiler: Object(java.lang.String) in Object cannot
//be applied to ()
}
String name = "ExtendsObject class ";
void speak() {
System.out.println("I am in " + name );
}
public static void main (String [] args) {
ExtendsObject e = new ExtendsObject();
}
}
I would be grateful if someone could explain to me what is going on here and we cannot just compile without super("H"); .
Also I am pretty sure that in another case the compiler wouldn't complain if I used super() (or omitted it which is the same thing)