Given:
2. class Shape { 3. static String os = ""; 4. void m() { os += "super "; } 5. } /*from w w w. j a v a 2 s.c om*/ 6. public class Main extends Shape { 7. public static void main(String[] args) { 8. new Main().go(); 9. } 10. void go() { 11. Shape s = new Main(); 12. Main c = (Main)s; 13. // insert code here 14. } 15. void m() { os += "cool "; } 16. }
If the rest of the code compiles, which line(s) of code, inserted independently at line 13, compile? (Choose all that apply.).
m()
;m()
;m()
;m()
;m()
;m()
;m()
;A, B, C, and D are correct.
A, B, and C will invoke Main's version of m()
, and D will invoke Shape's version of m()
.
E, F, and G are all illegal syntax to try to invoke Shape's version of m()
.
H is incorrect because the rest of the code is legal.