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); } }
Views 21
Answer:
Answer
- Method argument/Argument variable is n
- Class variable is x
- Local variable is a
- Instance variable is y
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.