If we define a variable or method as private, we can access them in subclasses only. This means if we define it as protected; then, whichever class is inheriting the parent class, only those subclasses can have access to the method, and no other classes. This can be understood with the following code snippet:
protected void abc() { //TODO Auto-generated method stub System.out.println("Hello"); }
The difference between default and protected is that in default we can access a class only within the same package of classes. Even protected can access all classes in the same package, except it has an additional feature. This additional feature says that, if we want to access it in other packages, only subclasses that inherit the properties ...