posted 8 years ago
As Henry already explained , I also want to give my opinion. Here you probably expected NullPointerException or ClassCastException. But that doesn't occur. NullPointerException occurs when you call a method/variable on reference variable which is null. So here you are not calling anything on references , so no chance of NullPointerException. ClassCastException occurs when you type cast super class reference to sub class reference type if super class reference variable is pointing to super class object. Here super class reference variable is not pointing to any object. So no chance of ClassCastException. Overall you don't get any exceptions here.