Page 1 of 1

About Question enthuware.ocajp.i.v7.2.945 :

Posted: Sat Aug 10, 2013 2:04 pm
by Statics
I was really confused about 2nd point - "A subclass can override any method in a non-final superclass". Even if "subclasses are allowed to define a new method with exactly the same signature", do they override methods of superclass?

Moreover, Java compiler fails to compile such code:

Code: Select all

    class A {
        private void doStuff(){}
    }

    class B extends A {
        @Override
        private void doStuff(){}
    }
So maybe it make sense to correct somehow this answer?

Re: About Question enthuware.ocajp.i.v7.2.945 :

Posted: Sat Aug 10, 2013 2:51 pm
by admin
This option seems be mistakenly set as correct because the explanation to this option says:
Only the methods that are not declared to be final can be overridden. Further, private methods are not inherited so they cannot be overridden either.
This has now been fixed.

thank you for your feedback!