Derived type Casting

11. Program ( Derived Type Casting )

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class A { } class B extends A { } class C extends B { } class D extends C { } class Manager14 { public static void main(String[] Args) { A a1 = new B(); B b1 =(B)a1; System.out.println("done"); } }

12. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class A { } class B extends A { } class C extends B { } class D extends C { } class Manager15 { public static void main(String[] Args) { B b1 = new C(); C c1 = b1; System.out.println("done"); } }

13. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class A { } class B extends A { } class C extends B { } class D extends C { } class Manager20 { static C test() { A a1 = new D(); return a1; } public static void main(String[] Args) { D d1 = test(); System.out.println("Done"); } }

14. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class A { } class B extends A { } class C extends B { } class D extends C { } class Manager21 { static C test() { A a1 = new D(); return (C)a1; } public static void main(String[] Args) { D d1 = (D)test(); System.out.println("Done"); } }

Page....