/ / Dynamische Bindung mit Konstruktor [Duplikat] - Java, Dynamic, Binding, Konstruktor

Dynamische Bindung mit Konstruktor [Duplikat] - Java, Dynamic, Binding, Konstruktor

Ich bin ein wenig verwirrt mit dem Bindungstyp eines Konstruktors. Warum rufst du an?

Canvas c = new Circle(); keine dynamische Bindung?

Vielen Dank!

Antworten:

0 für die Antwort № 1

Es ist statische Bindung, wie es während der Kompilierzeit getan wird.

Wenn die Klasse Circle über eine Methode verfügt, die eine Methode aus Canvas überschreibt, und Sie diese Methode wie folgt aufrufen, wird sie als dynamische Bindung bezeichnet.

//if you override some method in the child class that is Circle
c.someMethod() //example of dynamic binding

Du kannst lesen statisch vs. dynamisch für mehr.