If i change line 2 to public int a; then shouldn't it work?
You don't have to go that far. Changing it to "protected" will allow the subclass to compile. Heck, if both the super and sub are in the same package, then changing it to the default access will work too.
What happens to the default constructor when you add a non-default constructor to a class?
Joined: Apr 22, 2008
If there is a non default constructor in class then compiler will never put any default constructor by itself.
Programmer himself has to take care that there is no call to default constructors from its subclass.
As implicitly first line in a constructor is super() that is a call to default constructor of super class error may be produced.
So always call the non default constructors of super class yourself from sub class constructor using super(arguments).
One can also call the constructor in same class using this() or this(arguments).