Methods & Fields
About Method
Characteristics of a Method
public int add(int a, int b) { return a + b; }
void greet(String name) { System.out.println("Hello, " + name); }
int square(int num) { return num * num; }void display() { System.out.println("No return value"); }
Example of Methods in Java
Types of Methods in Java
1. Instance Methods
2. Static Methods
3. Abstract Methods
4. Final Methods
5. Synchronized Methods
About Field
Characteristics of a Field
Example of Fields in Java
Types of Fields in Java
1. Instance Fields
2. Static Fields
3. Final Fields
4. Transient Fields
5. Volatile Fields
Last updated