Types of Methods

A Method is a set of instructions that solve a particular task. There are majorly 3 types of methods in java, They are:
  1. Instance Methods
  2. Static Methods
  3. Recursive Methods
Instance Methods:
These are the methods that act upon Instance variables. These methods can be accessed only after creating the Object. The advantage of Instance methods is that they can access Instance variables as well as static variables. 
Static Methods:
A static method is declared by using a keyword "Static". Static methods does not act upon Instance variables. The reason why static methods cannot act on Instance variables is, the JVM first executes the static methods and then it creates Object, instance variables are created only after creating objects, since the objects are not available at the time of executing static methods, the instance variables are not accessed by Static methods.
Recursive Methods:
The phenomenon of calling the methods by itself is called as "Recursion", Such methods are called as "Recursive Methods". 

2 comments:

  1. WHAT ABOUT NATIVE METHODS.........

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete