A visibility modifier (a.k.a access modifiers or access specifiers) is a concept not tied to any specific programming language. It is a language keyword that precedes a declaration and defines the scope from where it is visible -thus can be accessed. Visibility Modifiers are modifiers that when appended to a class, interface, property or function in Kotlin, would define where all it is visible and from where all it can be accessed. The setters of properties in Kotlin can have a separate modifier from the property. There are four visibility modifiers in Kotlin
The declarations marked with the private modifier are visible inside the file/class containing the declaration.
The declarations marked with the protected modifier are visible inside the file containing the declaration and subclasses. This modifier is not allowed for top-level declarations.
The declarations marked with the internal modifier are visible everywhere in the same module.
The declarations marked with the public modifier are visible to everyone. public is the default visibility modifier in Kotlin (a declaration without explicit modifier will be public)
I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉
Have a nice a day! 🙂