Author Topic:   Overriding
ranch hand
posted March 28, 2000 12:12 PM             
Can the overriding method be final,native,synchronized and abstract. I tried it's working well. Is there anything i have to learn regarding this.One more thing if the method that's being overriden is abstract then can we make the overriding method native.Cause abstract methods require implementation in the subclass and native methods shouldn't provide any implementation right.


[This message has been edited by sree (edited March 28, 2000).]

maha anna
posted March 28, 2000 02:59 PM             
When a overridden method is abstract and the overriding method is native, you are in fact providing an implemetation through the local library. native method declaration does not have { }. This doesn't mean that it doesn't provide implementation for the overridden method. Look at the foll. example. I took it from R&H and slightly modified. This native method provides implementation , through a static initializer block when the class NativeExample is loaded into memory so that it will be ready before any call is made for that doSomethingLocal() method.

If 'MyNativeLib' can't be found by JVM it throws Runtime UnSatisfiedLinkError
maha anna

abstract class Base {
abstract void doSomethingLocal();
class NativeExample extends Base{
static {
native void doSomethingLocal();

public static void main(String[] args) {