Given the code fragment:



Which two modifications, made independently, enable the code to compile?

A. Make the method at line n1 public.
B. Make the method at line n2 public.
C. Make the method at line n3 public.
D. Make the method at line n3 protected.
E. Make the method at line n4 public.

題解

題目原本提供的程式會在line n3編譯錯誤,原因在於Earth類別繼承的Planet類別,其revolve方法的可見度使用protected來修飾。若要在Earth類別覆寫revolve方法,其可見度必須不能小於protected,因此Earth類別的revolve方法的可見度只能用protected或是public來修飾。