I am currently in the process of obtaining my Oracle certification and this is one of the concepts that I am failing to grasp. The following code snippet does not print true even though I expect it to:
interface I {
}
class A implements I{
}
class B extends A{
}
class C extends B{
}
public class Test {
public static void main(String... args) {
A a = new C();
B b =(B)a;
C c =(C)a;
a = null;
System.out.println(b==null);
}
}
Why do I expect a true? b was created using a and a has now been set to null.