+1 vote
in JAVA by

Difference between Default and Protected access specifiers.

Default: Methods and variables declared in a class without any access specifiers are called default.

default

Default members in Class A are visible to the other classes which are inside the package and invisible to the classes which are outside the package.

So Class A members are visible to the Class B and invisible to the Class C.

Protected:

Protected             .

Protected is same as Default but if a class extends then it is visible even if it is outside the package.

Class A members are visible to Class B because it is inside the package. For Class C it is invisible but if Class C extends Class A then the members are visible to the Class C even if it is outside the package.

Related questions

+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
...