Return to Coding in Java with artEoz – exercises

Inheritance and dynamic biding

  1. Make sure you have the calc resource. If necessary, see the Resources import webpage.
  2. Enter the code below. The Inherited attributes option inherited from the Options menu displays fields inherited from superclasses. What are the specific fields and inherited from an instance of Nombre? key_48 from an instance of Somme? key_48
  1. Display the evolution of the call stack in step-by-step mode. This stack shows, through the this pointer, the different receivers used to call the valeur() function. What are the different valeur() functions called? key_48
  2. Add the statements below. Note the static type of the e1 variable key_48. Both valeur() function calls are on the same variable. And yet, what do you see when running? key_48
  1. The choice of the good valeur() function is done at runtime. This mechanism has the dynamic link or dynamic binding name. The example below shows another example.