pessoal, gostaria q vcs analisassem essa questão:
1. public interface Interface1 {
2. void foo();
3. }
1. public interface Interface2 {
2. void foo(int i);
3. }
1. public interface Interface3 {
2. int foo();
3. }
1. public class InterfaceImpl implements Interface1, Interface2, Interface3 {
2. public int foo() {
3. return 0;
4. }
5. public void foo(int i) {
6. }
7. public static void main(String[] args) {
8. System.out.println ("Result: " + new InterfaceImpl().foo());
9. }
10. }
a resposta correta seria
Compilation fails, the compiler reports that the return type is incompatible with Interface1.
mas o certo não seria :
Compilation fails, the method void foo() from interface Interface1 is not implemented.
reparem que ele fala que o tipo de retorno e incompativvel… com o da Interface1 , so que na interface 3 que ele tbm implementa…possui um metodo com implementação correta na subclasse…
logo o metodo , void foo(); não foi implementada na subclasse…
o que eu nao to entendendo?
Obrigado.
