I just can't understand whyCode:class A { int a = 10; } class B extends A { int a = 20; } class C { public static void main(String[] args) { A a = new B(); // why does this work ?? B b = new A(); // why does this not ?? } }
BASE_CLASS <var_name> = new DERIVED_CLASS (will work)
DERIVED_CLASS <var_name> = new BASE_CLASS (will not work)
HELP !!!!!!!
Bookmarks