In this section, we will explore the concept of method
in the reference of object oriented programming techniques.
As we earlier described in the topic class,
a class have two major parts state and behavior. States are represented by
variables and behaviors are defined by methods.
- Method : An brief
Methods perform the most
important work in a class, object can't do anything without method. Some
programming languages use reflexive data structures to do the same action, they
have a complete set of data, but they don't have any behavior and due to this
they depend on other functions.
After taking a brief look on methods, now the next
question arises that, "what is method invocation?". There are two type
of method in java object-oriented technique first one is the Instance method and
the other one is the class method.
- Method Overloading
As we know that a method have its own signature which
is known by method's name and the parameter types. Java has a powerful feature
which is known as method overloading. With the help of this feature we can
define two methods of same name with different parameters.
- Method Overriding
is another useful feature of object-oriented programming technique. It provide the
facility to redefine the inherit method of the super class by a subclass. The
method overriding is used to invoking the parent class method by a child class.
A method's visibility is known as
method scope. We can say that it defines whether a object can invoke as well as
any subclass can override the method or not.