for most instance methods(except the methods that only be used internally)
private
only methods in this same class can access or use it
Encapsulation
restrict access to some of the object's fields, hide some information from other classes that use the object (to protect internals or misusing the object)
accessor, mutator methods
provide get/set methods if needed(the instance variables are private)
Since the name is private, main can't access to nameIn this case, we need an accessor and mutator methods(get/set)
set name through mutator(set) and print output using accessor(get)
accessor and mutator methods (get/set) let other use private variable
Why private variable?
Let say the public String name used in 5000 different places and later you need to modify the code which means it'll require you to modify 5000 other codes as well. However, the code was written with private, you can simply modify the accessor and the mutator.
static
needed to create class variables, class methods (do not refer to any one specific instance, but belong to the class as a whole)
class variable population and class method census using staticOutput : 1 2 3 3 3 3