Hi,
in self
test of chapter 1 of this great book I have found a strange question, the number 6.
1. public class Electronic implements Device
{ public void doIt() { } }
2.
3. abstract class Phone1 extends Electronic { }
4.
5. abstract class Phone2 extends Electronic
{ public void doIt(int x) { } }
6.
7. class Phone3 extends Electronic implements Device
{ public void doStuff() { } }
8.
9. interface Device { public void doIt(); }
This code will compile?
The answer is yes but I do not understand why.
I have tried it and compile fine, but line line 7 is a little strange for me because Phone extend Electronic that implement already the interface Device.
This little ambiguos for me to implement two time the same interface. As a test I have also tried to implement twice the same interface in a class and the compiler say "Duplicate interface Device for the type Electronic". There are some reference in the
Java Lang Spec that explain this behaviour?
Thanks