July 2017
Intermediate to advanced
796 pages
18h 55m
English
In this subsection, we will try to understand the access and visibility of Scala variables and different data types in the OOP paradigm. Let's have a look at access modifiers in Scala. A similar one for Scala:
| Modifier | Class | Companion Object | Package | Subclass | Project |
| Default/No modifier | Yes | Yes | Yes | Yes | Yes |
| Protected | Yes | Yes | Yes | No | No |
| Private | Yes | Yes | No | No | No |
Public members: Unlike a private and protected member, it is not required to specify the public keyword for public members. There is no explicit modifier for public members. Such members can be accessed from anywhere. For example:
class OuterClass { //Outer class class InnerClass { def printName() { println("My name is Asif Karim!") } class InnerMost ...Read now
Unlock full access