are b and bb references of the same object? No. Each identifier references a different object.
B b = new B(); From left to right: This declares that an identifier called
b of type
B exists, and then assigns a new
B object to the identifier
b -
b refers to a
B object.
A bb = new B(); From left to right: This declares that an identifier called
bb of type
A exists, and then assigns a new
B object to the identifier
bb -
bb refers to a
B object.
If you are having trouble understanding why such an arrangement is allowed, I suggest that you take a look at
The Campfire Stories - especially
The "How My Dog Learned Polymorphism" Story.
Good Luck.