Access Modifiers Available in Scala?

Hello Everyone, I am new in this community, I want to know different types of Access Modifiers available in Scala? I am preparing for a scala interview and this question was asked to me in my last interview. I have researched about this but I didn’t get an accurate answer. Can anyone know about the access modifier in the scala? Please suggest me some more important topics which help me in my upcoming interview.

Google: Access modifiers in Scala

Response:

public, private and protected are the three access modifiers used in Scala. Include the keywords private/protected/public in the definition of class, object or package to enforce the corresponding scope. If none of these keywords are used, then the access modifier is public by default.

LMGTFY: https://alvinalexander.com/scala/how-to-control-scala-method-scope-object-private-package/

1 Like

Note that there is no public keyword. That is the default visibility.

Official language specification: https://scala-lang.org/files/archive/spec/2.13/05-classes-and-objects.html#modifiers

1 Like

The restriction of scope to certain places is realized with the help of access modifiers. public, private and protected are the three access modifiers used in Scala . Include the keywords private/protected/public in the definition of class, object or package to enforce the corresponding scope.