Methods in Java
A method is a reusable block that does one job. Parts: return type, name, parameters, body. void means do the work and return nothing. int square(int n) returns a value.
Call it on an object: s.study(); or on the class if it is static: Math.max(2, 5). Keep methods small — one clear responsibility. Forgetting return in a non-void method is a compile error.
In an interview, write square(int n) live and explain each word of the signature.
Let's take this on the board with one tiny Main class — no extra files. Methods in Java — output: 25. square(5) is 5*5. Change to square(6) in your head — 36. Start from main, go line by line, and stop at each print. That output is the proof for Methods.
Explain signature: return type + name + params. Write square(int n).