public class Util {
public static int base = 100;
public static int boost(int x) {
return base + x;
}
}
// ...
System.out.println(Util.boost(5));
Util.base = 0;
System.out.println(Util.boost(5));What is printed?
- Acheck_circle
105 then 5
- B
5 then 5
- C
Compile-time error
- D
105 then 105
Explanation
First call uses base=100 returning 105; after setting base to 0, the second call returns 5.