Multiple choice technology programming languages

class C{ static int s; public static void main(String a[]){ C obj=new C(); obj.m1(); System.out.println(s); } void m1(); { int x=1; m2(x); System.out.println(x+""); } void m2(int x){ x=x*2; s=x; }}

  1. prints 1,2

  2. prints 2,0

  3. prints 2,2

  4. compile time error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

m1() declares local variable x=1 (not the static s). Java passes primitives by value, so m2(x) receives a copy - doubling x inside m2 doesn't affect m1's local x. m1 prints '1' then m2 stores 2 in static field s. Finally main prints s which is 2. Output: 1 2