Consider the following program: <span>class Main {
int a = 10;
public static void main(String[] args) {
add();
}
private static void add() {
int b = a+20; System.out.println(b);
}<span> }
The output of the above program is 30. As you can see the variable a is declared outside the method, whereas variable b is declared inside the method.</span></span>