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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!