Quiz · Classes and objects · lesson 8 of 10
Quiz — an object counter
What does the program print?
public class Main {
public static void main(String[] args) {
Counter a = new Counter();
new Counter();
System.out.println(Counter.count + " " + a.id);
}
}
class Counter {
static int count;
int id;
Counter() { id = ++count; }
}