1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Object Oriented Programming (OOP) in Kotlin

Access (Visibility) Modifiers in OOP

Access (Visibility) Modifiers in OOP
1h 31m

This course covers the concept of Object-Oriented Programming in Kotlin, which is a method of designing and implementing software. It simplifies software development and maintenance by providing concepts such as object, class, inheritance, polymorphism, abstraction, and encapsulation. This course will explore those.

Intended Audience

This course is ideal for anyone who wants to learn how to use Kotlin for developing applications on Android.


This content will take you from a beginner to a proficient user of Kotlin and so no prior experience with the programming language is required. It would, however, be beneficial to have some development experience in general.


Course GitHub repo: https://github.com/OakAcademy/Kotlin-Programming-Course/tree/main/ObjectOrientedProgramming


Well, hello everyone. So, in this video here we're going to learn access modifiers or visibility modifiers in Kotlin. Access modifiers are used for setting the access level to classes, variables, functions, and constructors. There are four access modifiers in Kotlin, and to be specific, the first one is private. So, the private access modifier is accessible only within the class. Methods, variables, and constructors that are declared private can only be accessed within the declared class itself. The private modifier is the most restrictive access level. The second one, is protected. The protected access modifier is accessible only within the same class and additionally from all the subclasses of its class. The third one, is internal. So, the internal visibility modifier means that the member is visible within the same module. More specifically, a module is a set of Kotlin files compiled together, such as intelliJ IDEA module or a Maven project. And the last one would be public. So, a public access modifier is basically accessible from everywhere. This is the least restrictive access modifier. So, here you can have a look at the restrictive level of accessibility of modifiers.

And as you can see, the most restrictive modifier is private. Least restrictive modifier is public. And then protected comes after private, and internal comes after protected. So, you don't have to use access modifiers when you're creating any object. I mean this will not cause any errors. When you do become a good developer in the future though, while working with different developers on really large projects, you may sometimes need to restrict the access of some of these other developers to the objects that you create. So, what that does is prevent other software developers from using the objects that you have created. And it basically creates a more efficient working environment. So, these cases you may need to access modifiers here. And we generally use private or public access modifiers in our projects, but like I just mentioned, it's okay if you don't use them. Finally, I should point out though that if you do not specify any visibility modifier, public will be used by default, which means that your declarations will be visible everywhere. Just keep that in mind, my friend. All right, so we'll just take a short break here. We're going to talk about naming conventions in the next video. So, hang out and I'll see you then.


About the Author
Learning Paths

Mehmet graduated from the Electrical & Electronics Engineering Department of the Turkish Military Academy in 2014 and then worked in the Turkish Armed Forces for four years. Later, he decided to become an instructor to share what he knew about programming with his students. He’s currently an Android instructor, is married, and has a daughter.

Covered Topics