Given:
2. class Shape { 3. protected static String s = ""; 4. final void grow() { s += "grow "; } 5. static final void growFast() { s += "fast "; } 6. } 7. public class Square extends Shape { 8. void grow() { s += "t-grow "; } 9. void growFast() { s+= "t-fast "; } 10. }
Which are the FEWEST change(s) required for this code to compile? (Choose all that apply.)
grow()
must be marked final.grow()
must NOT be marked final.growFast()
must NOT be marked final.growFast()
must NOT be marked static.growFast()
must be removed from the class.C and F are correct.
Square can already access s.
If Shape.grow()
is NOT final, then Square can override it.
In order for Shape.growFast()
to be overridden, two changes (D and E), must occur, so for this question, it would require FEWER changes to remove Square.growFast()
and not attempt an override.
We don't like this kind of question either, but you may encounter some like it on the real exam.