In Java, an Object
can have a runtime type (which is what it was created as) and a casted type (the type you have casted it to be).
I\'m wondering what
I think it's important to distinguish between the object (which exists at execution time, and just has its execution time type) and an expression (such as a variable) which has a compile-time type.
So in this case:
A a = new B();
a
is a variable, of type A
. Its value at execution time is a reference to an object of type B
.
The Java language specification uses "run-time class" (e.g. for the purpose of overriding, as in section 15.12.4.4) for the type of an object. Elsewhere I think it just uses "type" for the type of an expression, meaning the compile-time type.
I would say that you differentiate between the type of the variable/reference and the type of the object. In the case
A a = new B();
the variable/reference would be of type A
but the object of type B
.