Methods/ Functions
Definition of method:- These are also known as functions, procedures, modules, subroutines,sub programs. In simple words it is a collection of statements which are going to perform a particular task. They don't do anything until they are called(executed). They can be used(called)as many number of ti
Definition of method:-
These are also known as functions, procedures, modules, subroutines,sub programs. In simple words it is a collection of statements which are going to perform a particular task. They don't do anything until they are called(executed). They can be used(called)as many number of times as required.
The syntax of the method is given below.
[Access specifier][type][return type][name of the method](Argument list)
{
// Method code
Method body
}
For Example:
public static void main(String args[])
{
//Code
}
There are two types of methods.
- System defined methods: They are also called library methods, built in methods.these are defined by java. All the methods of Math class, String class are example of system defined methods.
- User defined methods:- The methods defined by user are called user defined methods. Advantages of methods:-. -Code re usability -Divide complex Programs into manageable code. -Improves the readability. -Makes debugging easier.
Method (function)definition:- It has two parts method header and method body.
Method (function)prototype: The first line of the method definition is called method prototype/method header.
Example public add(int a , int b)
Method(function) signature: Method name and list of parameters is called method signature.
Example add(int a, int b)
Types of methods:
Pure Method:- A method that does not change the original state of an object is called a pure method. It always return the same value when the same arguments are given.
Impure Method:- A method that changes the original state of an object is called an Impure method. It does not return the same value when the same arguments are given.
Static method:
The method which can be accessed without an instance of the class are known as static method. It can be invoked using the class name(Math.pow(2.0,3.0)) or only with the method name also(add(4,5)).
These methods are created with static keyword.
Non static method:
The method which are accessed through an instance of the class are known as non static method.
For example:
Student obj=new Student();
obj.study();
These methods are not created with static keyword.
Related Posts
Continue learning with these related articles

User-Defined Methods in Java for ICSE Class 10: Parameters, Return and Overloading
ICSE Class 10 Computer Applications notes on user-defined methods: method prototype and signature, formal and actual parameters, return types, call by value vs call by reference, pure and impure methods, static methods and method overloading, with programs.

ISC Practical 2027: Image Editor – Brighten an Image and Find Bright Spots (2-D Array) – Java Program
Fully solved ISC Computer Science Practical 2027 2-D array question: brighten a grayscale image (capping values at 255) and find the bright spots, pixels larger than all four neighbours. Includes a missing bright spot in CISCE’s sample output.

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.