But since type of reference is Book, we need that class Book has mA method. It really has it. But we must `execute` this method from Encyclopedia object, and since this method (in Encyclopedia object) is not compile, how could we `execute` it?
Sorry but I am not sure what you mean by "and since this method (in Encyclopedia object) is not compile". Can you be a bit more clear about what you mean by this so that I can address your confusion?
Remember that final just means that a subclass cannot override it. It doesn't mean the subclass cannot access it or can not inherit it. This is OCAJP stuff
I just try to understand if the line //2 will cause compilation to fail, then how could we run method o1.mA()? Since this method is fail to compile. By this logic the line //4 should not compile too?
I have passed OCA (81%) ))
Sergey wrote:In other words, how could we run something if this "someting" is not compiled?
Line marked //2 doesn't compile because it is trying to override a final method. There is no problem with line marked //4 because Encylopedia inherits method mA() from Book.