I have a question for referencing variables. My question is, does the type of the declared variable refer to the type of the object or to the type of the link that is stored in it?
I found a very interesting answer by Edwin Dalorzo about
this topic. It describes that each link has a type, and when we perform type casting, it only changes the type of link used to refer to this object (and not the type of this object itself!).
So my question is whether the type of the reference variable indicates the type of link in it. Of course, the type of the object and the type of link are the same.
Suppose B a = new B();
B is currently telling the compiler that the bindings are of type B?
Or does the compiler completely ignore the type of data that is stored in it (link), and only think about the type of the underlying object? The same goes for the type of the return method.
source
share