Learn Java Programming - Polymorphism and Instance Variables Tutorial

Pubblicato il: 06 settembre 2015
sul canale di: Daniel Ross
929
13

In my previous polymorphism tutorials I discussed the principle of polymorphic method invocation. At runtime, the JVM determines which method to invoke based on the type of the object, not the type of the reference variable. Since polymorphism applies to instance methods, does polymorphism apply to instance variables? The answer is no, polymorphism does not apply to instance variables.

Can we override an instance variable just like we can override an instance method? Technically NO, but there is more to it. While it is true that subclasses inherit members of a superclass – and that includes accessible instance variables – simply declaring an instance variable in the subclass with the same type and name merely 'hides' the inherited superclass instance variable.


In questa pagina del sito puoi guardare il video online Learn Java Programming - Polymorphism and Instance Variables Tutorial della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Daniel Ross 06 settembre 2015, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 929 volte e gli è piaciuto 13 spettatori. Buona visione!