differentiate between private access specifier and protected access specifier in java
Answers
Explanation:
A private member ( i ) is only accessible within the same class as it is declared. A member with no access modifier ( j ) is only accessible within classes in the same package. A protected member ( k ) is accessible within all classes in the same package and within subclasses in other packages
ANSWER :-
♥️ Protected access specifier :-
Protected access modifier is similar to that of private access modifiers, the difference is that the class member declared as Protected are inaccessible outside the class but they can be accessed by any subclass(derived class) of that class.
♥️ Private access specifier :-
The class members declared as private can be accessed only by the functions inside the class. They are not allowed to be accessed directly by any object or function outside the class. Only the member functions or the friend functions are allowed to access the private data members of a class.