Which statements, when inserted at (1), will cause a compilation error?.
public class Main { static void main(String[] args) { int a = 0;/*w w w.ja v a 2 s.co m*/ final int b = 1; int[] c = { 2 }; final int[] d = { 3 }; useArgs(a, b, c, d); } static void useArgs(final int a, int b, final int[] c, int[] d) { // (1) INSERT STATEMENT HERE. } }
Select the two correct answers.
(a) and (f)
A value can only be assigned once to a final variable.
A final formal parameter is assigned the value of the actual parameter at method invocation.
Within the method body, it is illegal to reassign or modify the value stored in a final parameter.
This causes a++ and c = d to fail.
Whether the actual parameter is final does not constrain the client that invoked the method, since the actual parameter values are assigned to the formal parameters.