Skip to main content
added 46 characters in body
Source Link

Protected : VISIBLE only to package level*.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Same applies to private defined classes.

Note : Nested or inner classes can be defined protected or private.

* : Explore protected keyword, for this answer I made it succinct.

Protected : VISIBLE only to package level*.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Note : Nested or inner classes can be defined protected.

* : Explore protected keyword, for this answer I made it succinct.

Protected : VISIBLE only to package level*.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Same applies to private defined classes.

Note : Nested or inner classes can be defined protected or private.

* : Explore protected keyword, for this answer I made it succinct.

added 80 characters in body
Source Link

Protected : VISIBLE only to package levellevel*.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Note : Nested or inner classes can be defined protected.

* : Explore protected keyword, for this answer I made it succinct.

Protected : VISIBLE only to package level.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Protected : VISIBLE only to package level*.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.

Note : Nested or inner classes can be defined protected.

* : Explore protected keyword, for this answer I made it succinct.

Source Link

Protected : VISIBLE only to package level.

class is defined protected ---> it cannot be extended from outside package(not visible).

And if it cannot be extended then it is meaningless to keep it as protected, because then it will become default access which is allowed.