- Method proto type (or) Method header
- Method body .
Method proto type
This part contains method name, method parameters and method return type.
Method body
Method body contains a group of statements representing the logical to perform the task.
NOTE:
A method can return a value using return statement. It cannot return more then one value.
Methods in Java
- Static Methods
- Instance Methods
- Factory Methods
Static Methods
A static method is a method that don’t act upon the instance variables. We can call static methods by using it’s class name or object name.
NOTE:
Static Methods Cannot access or read instance variable because JVM first executes the static methods and later creates the objects.Instance Methods
Instance methods are methods which are act’s upon the instance variables. These are the two types one is accessor methods and another one is mutator methods.
Factory Methods
Factory method is method that returns an object of that class tp which it belongs.
No comments:
Post a Comment