Mark As Completed Discussion

Public

Public is the most open access modifier. If a variable/attribute has a public modifier, then any other object can easily access it via the . (dot) operator.

Below are major things you need to keep in mind when using the public keyword.

  1. There can only be one public class in a single file in Java.
  2. The file name should be the same as the class name.
  3. It is considered bad practice to make more public attributes and class methods than necessary.