Please use the Code button otherwise your code is illegible.
That is a good example of confusing code. You say you have class C2 and then write C4. Writing C1 C2 C3 and C4 is guaranteed to confuse people. Also some bad design, with public fields.
The real problem is that the method in C2 does not override that in C1. You can try adding the @Override annotation to C2#met1. The explanation is in your own post . . .
In all classes met1() function uses default (package-private) specifier which is visible to the class and its own package. As C1 and C2 classes are under different package, C2.met1() not overiding the function from base class C1.met1(). On invoking o2.met1(); it invokes C1.met1() function.
Joined: Dec 27, 2008
thanks for your time..thanks
@ Campbell Ritchie
hey thanks for your time..
Sorry for confusing C2 and C4....
Will use code button next time...did not know about the code button while i was posting my Q.