Hi guys. I hope you're doing well. I'd like to see if you share my conclusion about the following cases:
* CASE 1
If we have an interface declaring a method and then a class that overrides that method in a wrong way, then, the subclass of this last class is obligated to override the method in the right way in order to compile. If it is not done, this class will inherit the wrong implementation.
-> Lines 2 and 4 do not compile.
* CASE 2
Unlike case 1, if we have a class (instead of an interface) that implement a method and then a subclass that override it in a wrong way, then if there is a third class that inherit from the last one and it does not properly override the method, there won't be any issue and anyway it will be compile.
1 class HasTail{ protected int make(){ return 2; } }
2 class TestExt extends HasTail{ int make(){return 4;} }
3
4 class Test2 extends TestExt{
5 //public int make(){ return 0; }
6 public static void main(
String[] args){
7
8 }
9 }
-> Only line 2 does not compile while Test2 class compiles.