Answer the question
In order to leave comments, you need to log in
Why is it not necessary to specify an access modifier in interfaces?
When you try to specify an access modifier, the IDE prompts you to remove it with no other options. When implementing these methods inside classes, they are declared as public and, again, this cannot be changed. What is the reason for this, why exactly?
Answer the question
In order to leave comments, you need to log in
The very concept of "interface" implies access from the outside. Therefore methods must be public.
> When implementing these methods inside classes, they are declared as public and, again, this cannot be changed. What is the reason for this, why exactly?
Try to answer the question, why do you need an interface for private methods? Along the way, you will get an answer to your question.
This is due to the fact that the interface is always the "tip of the iceberg" which hides the implementation itself in the future. You can think of it as a point of interaction.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question