Given that:
and
2. import java.io.*; 3. class Shape { 4. protected void write() throws IOException { } 5. } /*from w w w . j ava 2 s. c om*/ 6. public class Square extends Shape { 7. private void write(int x) { } 8. protected void write(long x) throws FileNotFoundException { } 9. protected void write(boolean x) throws Exception { } 10. protected int write(short x) { return 7; } 11. public void write() { } 12. }
What is the result? (Choose all that apply.).
A is correct.
All of the overrides and overloads are legal.
B, C, D, E, and F are incorrect because it's legal for overloaded methods to have different return types, throw different exceptions, and have different access modifiers.
Overridden methods have stricter requirements, but lines 7-10 are overloaded methods.
Line 11 is an overridden method, and it's legal for overridden methods to have fewer exceptions and less restrictive access modifiers.