shanky sohar wrote:it its true that private methods are being called at compile time only.
What do you mean by that?
my above statement is little bit confusing so i am reiterating it
in case of overriding,as we all know that at compile time refernce type of the class point to a method to which it will called but actual method will be called at runtime..
but when we say private to any method then it is not available outside the class.
then how can we override it.
so in that case refernce type of the class will point to that private method and calls it at runtime
so no overiding is possible.
and if the method is not available in the class then it shows compile time error
Campbell Ritchie wrote:No, private is not synonymous with final. Neither a final method nor a private method can be overridden, but the two words are not synonyms.
Very true indeed.
There is a very clear distinction. A final method cannot be overridden, period. A private method cannot be overridden, but it can still be shadowed. A sub class can have a method with the same name and parameter types, and because it's not overriding the return type can even be completely different. With final this is not allowed.