In the program given below, state the name and the value of the i. method argument or argument variable ii. class variable iii. local variable iv. instance variable
Advertisements
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);
}
}Short Answer
Advertisements
Solution
- Method argument or argument variable n with value 5.
- Class variables: x with value 7.
- Local variable: a with value 6.
- Instance variable: y with value 2.
shaalaa.com
Is there an error in this question or solution?
