With these it helps protected is used mainly for utility and helper methods inside a class. They are not meant to be accessible from outside, like private methods. However it could be necessary for an extending class to access those methods or even to modify them. So basically it is like private, whose right to exist should be clear, but you want to give extending classes the chance to also access it.
I hope this helps you . "Unreachable statement" means that there is no path in your code that can get you to this line in your program. It has nothing to do with protected fields. Check, if there is a return statement before your a+=1 that always exits your method before this line is ever reached. Or, if your a+=1 is in an if-block that is never executed, because the condition you specified always evaluates to false.
will be helpful for those in need Protected variable can accessible in subclass when it is in the same package.If BFrag is in different package then you can not access the super class protected variable in subclass.