What is the output of the following code? (Choose all that apply)
1: interface Printable { 2: public default int getPageNumber(int input) { return 2; } 3: } 4: public class Shape implements Printable { 5: public String getPageNumber() { return "4"; } 6: public String getPageNumber(int input) { return "6"; } 7: public static void main(String[] args) { 8: System.out.println(new Shape().getPageNumber(-1)); 9: } 10: }
E.
The code doesn't compile because line 6 contains an incompatible override of the getPageNumber(int input) method defined in the Printable interface.
int and String are not covariant returns types, since int is not a subclass of String.
line 5 compiles without issue; getPageNumber() is an overloaded method that is not related to the parent interface method that takes an int value.