public class K {
private static int n = 0;
public static void inc() { n++; }
public static int getN() { return n; }
}
// ...
K.inc(); K.inc();
K k = new K();
k.inc();
System.out.println(K.getN());What is printed?
- Acheck_circle
3
- B
2
- C
1
- D
0
Explanation
The static counter n is incremented three times in total regardless of how inc is called.