Can a private method be overridden by a subclass ? Ref:
SCJP Study Guide 5 by K & B on page 31.
I tried the following code :-
// ONE.
java package testsubclasssinheritance;
public class One {
private void myMethod(){
System.out.println ("This is my private from method One");
}
}
// TWO.java
package testsubclasssinheritance;
public class Two extends One {
public void myMethod(){
System.out.println ("This is my private from method Two");
}
public static void main (
String[] args){
Two t = new Two();
t.myMethod();
}
}
// RESULT
The result was the code compiled an printed out
"This is my private from method Two"
// QUESTION
Does that mean that the private method can be OVERRIDDEN ???