3
P4nda
5y

Hi, so currently in my Java course, I'm learning about abstract classes. I noticed how a method in an abstract class can use an access modifier, however, interfaces don't use them.
In addition to this, I noticed that IntelliJ didn't give me an error stating that adding an access modifier was redundant or useless. So I wanted to know if there is a point in adding access modifiers to abstract methods.
Thanks so much for anyone who can help me out with this!

Comments
  • 1
    Abstract methods can be anything (visibility wise) other than private. Nothing stopping you specifying a protected abstract method for example.

    Method definitions in interfaces though are always public (ignoring Java 8+ with static / default methods), so the public visibility modifier is always redundant.
Add Comment