✏️ Explanatory Question

 In the program given below, state the name and the value of the:

  1. method argument or argument variable
  2. class variable
  3. local variable
  4. 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);
    }
}

👁 97 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

Answer

  1. Method argument/Argument variable is n
  2. Class variable is x
  3. Local variable is a
  4. Instance variable is y