Given:
2. class Shape { 3. public class Rectangle { 4. static int count = 0; 5. void go() { System.out.print(" pump " + ++count); } 6. } //from w ww .j a v a 2s. com 7. public Rectangle getRectangle() { return new Rectangle(); } 8. } 9. public class Main { 10. public static void main(String[] args) { 11. Shape e = new Shape(); 12. // Shape.Rectangle p = e.getRectangle(); 13. e.Rectangle p = e.getRectangle(); 14. p.go(); p.go(); 15. } }
In order for the code to compile and produce the output " pump 1 pump 2", which are true? (Choose all that apply.).
B and C are correct.
Regular inner classes cannot have static declarations, and line 12 (not line 13), uses the correct syntax to create an inner class instance from outside the enclosing class.
The rest of the code is correct.