How can we restrict access of any protected method to only subclass in any package not to the class in the same package.
If any class that is not the subclass and in same package also it must throw exception like "Protected method."
Edit : Is there any way to check calling class name instance and then we can verify using instanceof .