Given:
2. public class Main { 3. static int count = 0; 4. Main() { // w w w . j a va 2 s .c om 5. while(count < 10) new Main(++count); 6. } 7. Main(int x) { super(); } 8. public static void main(String[] args) { 9. new Main(); 10. new Main(count); 11. System.out.println(count++); 12. } 13. }
What is the result?
B is correct.
It's legal to invoke "new" from within a constructor, and it's legal to call super()
on a class with no explicit superclass.
On the real exam, it's important to watch out for pre and post-incrementing.