What is the output of the following Java program?
class Counter {
static int n;
int id;
Counter() { id = ++n; }
}
public class Main {
public static void main(String[] args) {
new Counter(); new Counter();
Counter c = new Counter();
System.out.println(c.id + " " + Counter.n);
}
}- A1 3
- B3 1
- C3 3
- D0 3
Correct answer: C