Question: I don't understand why the first code doesn't work but the second one does. 2.10 Does this code compile? If it does, what is its

I don't understand why the first code doesn't work but the second one does.
2.10 Does this code compile? If it does, what is its output? class A 1 public class B extends A public static void main(String [] args) -[ B a Syst (B) new A(); em. out.println("works"); ClassCastException 2.11 Does this code compile? If it does, what is its output? class A 1 public class B extends A public static void main(String [] args) -[ A a - new B(); B b- (B)a; System.out .println(" works"); works
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
