Scala’s access modifier is different from Java:
Java defaults to package internal visibility if you don’t specify any access modifier. Scala, on the other hand, defaults to public.
Java provides an all-or-nothing proposition. Either it’s visible to all classes in the current package or it’s not visible to any. Scala gives fine-grained control over visibility.
Java’s protected is generous. It includes derived classes in any package plus any class in the current package. Scala’s protected is akin to C++ and C#—only derived classes can access it. However, you can also ask Scala for quite a liberal and flexible interpretation of protected.
Finally, Java encapsulation is at the class level. You can access the private