This is how I encountered the problem. I am giving an example:
package check;
public class Check {
int a,b;
Check (int i,int j) {
a = i;
b = j;
1) Why is it compulsory to use a constructor at all for class V? AFAIK, creating a constructor is not necessary as JAVA compiler creates default constructor automatically to carry on its operation. Also from the message, it also seems a default constructor is needed, but is not written by me, but as I said doesn't JAVA create it automatically?
A default constructor is only created when no other constructor exists, when you created the constructor Check(int i,int j) you removed the default constructor.
When you do not include a call to super within a constructor java attempts to call super() by default. However as there is no default constructor in the parent class it cannot do this.
This behaviour is good because you may not want a default constructor; certain variables may have to be initialised for the object to behave correctly. As such there needs to be a way to remove the default constructor, and this is done by explicitly creating a constructor.
2) Another thing, I changed the code in subclass as V(int i, int j){ super.a=i; super.b=j}., but I was still getting error. Why is that? Isn't this code super.a=i; super.b=j same with super(i,j)? Also, in class V, I might not need to use b, then why should I need to initialize it by a constructor?
The code
V(int i, int j){
super.a=i; super.b=j
}
still has no call to a parent constructor, as such becomes
V(int i, int j){
super();
super.a=i; super.b=j
}
And again super() does not exist
Some call to super must exist to "set up" the parent parts of the object, all the way down to Object (which all objects implicitely extend). As such you cannot omit the parent constructor simply because you do something equivalent in the child constructor