Class-Friendship via Interface
When one class wants to access the private method/attribute of another class, it is not generally possible but possible via a CLASS Friendship.
This is the usual class friendship that allows access to the private methods/attributes.
Output:
This friendship principle is possible via the interface also. The first class grants friendship to the interface and other class(es) if implement(s) this interface then it gets the permission to access the private methods/attributes. Below is the example:-
Output:-