How many final modifiers would need to be removed for this application to compile?
package mypkg; /* w w w .j av a 2 s . c om*/ public final class Main { public final static int finish(final int score) { final int win = 3; final int result = score++ < 5 ? 2 : win; return result+=win; } public static void main(final String[] v) { System.out.print(finish(Integer.parseInt(v[0]))); } }
C.
The finish()
method modifies two variables that are marked final, score and result.
The score variable is modified by the post-increment ++ operator, while the result variable is modified by the compound addition += operator.
Removing both final modifiers allows the code to compile.
For this reason, Option C is the correct answer.