oop - Dynamic dispatch and type checking mechanism in Java -


i understand how object in java internally represented consisting of "pointers" fields , functions in vtables , how these internal representations change when there assignments, implicit casts , explicit casts done, , how static , dynamic type checking works.

consider example extended from: dynamic method dispatch in java

class a{ int a=10;    public void show(){      system.out.println("show a: "+a);     } }  class b extends a{ public int b=20;     public void show(){     system.out.println("show b: "+b);     } }  class c extends b{ public int c=30;     public void show(){     system.out.println("show b: "+c);     } } 

how objects constructed in memory? happens when there assignment (or equivalently parameter passed)? difference in memory-represenation of object in following cases?

b bobj = new b();  aobj = new b();  c cobj = new b(); 

what happens in memory-representation when there explicit up/down casting? how check if such cast allowed , how change internal representation , method call dispatching information.

((a) new a()).show() ((a) new b()).show() ((a) new c()).show()  ((b) new a()).show() ((b) new b()).show() ((b) new c()).show()  ((b) new a()).show() ((b) new b()).show() ((b) new c()).show()  ((a) xobj).show() //xobj being unknown object ((b) xobj).show() ((c) xobj).show()  ((c) ((a) new b())).show() 

i've looked sources on these topics haven't found one. if topic broad helpful if given direction towards can study this.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -