Calculation Utility
A class provides both static utility methods for general arithmetic and instance methods to retrieve stored state.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
static class MathBox {
int val;
MathBox(int v) {
val = v;
}
static int combine(int a, int b) {
return a + b;
}
int getVal() {
return val;
}
}
public static void main(String[] args) {
MathBox m = new MathBox(7);
System.out.print(MathBox.combine(m.getVal(), 3));
}
}
A
3
B
10
C
7
D
0
Question Leaderboard
Not enough data yet to show leaderboard.
