Explanatory Question
In the program given below, state the name and the value of the:
- method argument or argument variable
- class variable
- local variable
- instance variable
class MyClass{ static int x = 7; int y = 2; public static void main(String args[]){ MyClass obj = new MyClass(); System.out.println(x); obj.sampleMethod(5); int a = 6; System.out.println(a); } void sampleMethod(int n){ System.out.println(n); System.out.println(y); } }
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.