多项选择题

Given:
2. class Engine {
3. public class Piston {
4. static int count = 0;
5. void go() {System.out.print(" pump " + ++count); }
6. }
7. public Piston getPiston() {return new Piston(); }
8. }
9. public class Auto {
10. public static void main(String[] args) {
11. Engine e = new Engine();
12. // Engine.Piston p = e.getPiston();
13. e.Piston p = e.getPiston();
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.)

A.The code is correct as it stands.
B.Line 4 must be changed, count can"t be declared "static"
C.Line 12 must be un-commented, and line 13 must be removed.
D.Somewhere in the code, a second instance of Piston must be instantiated.
E.There are errors in the code that must be fixed, outside of lines 4, 12, and 13.
题目列表

你可能感兴趣的试题

微信扫码免费搜题