Why is early binding permitted at compile time if the actual object is determined at run time?

I know that all objects are created at runtime when a function is called.

Binding is when we bind the members of these methods inside the class.

early binding binds all method instance variables at compile time. I thought that all objects are created at runtime, so it should also bind all elements of the given methods at runtime.

Why, with early binding, is an object method call defined at compile time? if this object is created at runtime.

eg.

class A{
    public void foo(){
        //some code here
    }
}

public static void main(String[] args){
    A aInstance = new A();
    aInstance.foo();
}

foo () was resolved at compile time, but aInstance is determined at runtime.

+3
source share
1

, ( ), , .

, .

, ; , VMT.

0

All Articles