228k views
1 vote
What is the output of the following program?

public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+" , ");
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}

a) 1 , 3
b) 3 , 1
c) 1 , 1
d) 1 , 0
e) none of the above.

User Enkryptor
by
4.2k points

1 Answer

4 votes

Answe:

none of the above

Explanation: non-static method m(i) cannot be cannot be referenced from a static context

Step-by-step explanation:

User Soumitra Goswami
by
5.1k points