Java OCA OCP Practice Question 1854

Question

What will the following program print?

public class Main{
  static int i = 10;
  public static void m(int a){
      a = 20;//from   w  ww.  ja  v  a2s  .co m
  }
  public static void main(String [] args){
      m(i);
      System.out.println(i);
  }
}

Select 1 option

  • A. 10
  • B. 20
  • C. It will not compile.
  • D. It will throw an exception at runtime.
  • E. None of the above.


Correct Option is  : A

Note

In case of primitives such an an int, it is the value of the primitive that is passed.




PreviousNext

Related