On this piece of code I understand it works with either super(t) in Class A or a no args constructor in class B. Below the code uses the no args constructor in class B. I understand that if you take the no args constructor out of class B the code does not work. I'm new to programming and what I'm trying to understand is what is so special about the no args constructor in class B, Why does it have to be present for the code to work? What is the special condition or rule?
public class Test {
public static void main(String[] args) {
B b = new B(5);
}
}
class A extends B {
public A(int t) {
System.out.println("A's constructor is invoked");
}
}
class B {
public B() {
}
public B(int k) {
System.out.println("B's constructor is invoked");
}
}