About Question enthuware.ocpjp.v21.2.3725 :
Posted: Thu Sep 11, 2025 11:57 am
A ac = new C();
if (ac instanceof B b1) {
...
}
- ac → at runtime this is a C object.
- instanceof B → evaluates to true because C is a subclass of B.
- If the test is true, the variable b1 is created and bound to the same object that ac is pointing to, but typed as B.
Hello, is this what happens here?
if (ac instanceof B b1) {
...
}
- ac → at runtime this is a C object.
- instanceof B → evaluates to true because C is a subclass of B.
- If the test is true, the variable b1 is created and bound to the same object that ac is pointing to, but typed as B.
Hello, is this what happens here?