Um exercício me deixou bastante intrigado na parte de Declarations and Access Control (Capítulo 2) do livro de Kathy Sierra.
No exercicio 3 segue o seguinte código.
-
Given the following,
-
abstract class A {
-
abstract short m1() ;
-
short m2() { return (short) 420; }
-
}
-
abstract class B extends A {
-
// missing code ?
-
short m1() { return (short) 42; }
-
}
which three of the following statements are true? (Choose three.) (Segue em negrito as corretas)
A. The code will compile with no changes.
B. Class B must either make an abstract declaration of method m2() or implement
method m2() to allow the code to compile.
C. It is legal, but not required, for class B to either make an abstract declaration of method
m2() or implement method m2() for the code to compile.
D. As long as line 8 exists, class A must declare method m1() in some way.
E. If line 6 were replaced with ?class B extends A {? the code would compile.
F. If class A was not abstract and method m1() on line 2 was implemented, the
code would not compile.
–
Eu não entendi o motivo da resposta C ser correta,
não sei se foi um erro de tradução meu, mas aí diz que é legal fazer a declaração abstrata do metodo m2 que é implementado
em class A em class B?

