Note that when a thread is started (using thread.start()) its
run() method is executed. In the following code:
1st case:
The code on
line 12 overrides the
MyThread class's
run() method. Hence the result: foo
Overrides method: lets say it replaces the code within the method, in this case.
2nd case:
The
run() method is not overridden, in this case. Hence the result from the original run method: Bar
Having the line
public void run(String s) { System.out.println("foo"); has no consequence in both cases, in this example.
SCJP 5, OCPJP 7, 8, SCJD 5, SCWCD 4, SCBCD 5, SCJWS 4, IBM OOAD 833 & 834, MongoDB Developer