This feature of object-oriented languages is known as method overloading . Instance methods can be invoked only by being associated with an instance of an object. Also, an object containing the instance methods must be instantiated with new before its instance methods can be called. Also, notice that we declare the methods and data belonging to the class Point using either the public or private modifiers. A public declaration allows the method or data to be accessed from outside the class.
Private declaration allows the data or methods to be accessed from only within the class.
Thus, the data for the class are accessible through only those methods that are defined within the class. Declaring data as private prvents the data from being manipulated from outside the class. These methods are defined as public, mening that they can be called by code outside of the class. Therefore, the designer of a class can determine how the class data are accessed and manipulated by restricting access to private class data through public methods. Note that there are instances where data may be declared as public and methods as private.