Question 17 (1 point) Look at the following code: Line 1 blic class ClassA Line
ID: 3918983 • Letter: Q
Question
Question 17 (1 point) Look at the following code: Line 1 blic class ClassA Line 2 Line 3 Line4 Line Line ublic class ClassB extends ClaSSA Line 7 Line 8 Line S Line 10 Line 11 blic class ClassC extends ClassB Line 12 Line 13 Line 14 Line 15 public ClassAO public void methodl (int a)) public ClassBO public void methodl0 public ClassCO public void methodl0 Which method1 will be executed when the following statements are executed? ClassA item! new ClassB(); itemi.methodi 0 O Line 4 Line 9 Line 14 This is an error and will cause the program to crash.Explanation / Answer
Answer: Line 9
Explanation: Its a classic example of Method Overriding. We create Class A reference and create Object of Class B and assign to Class A
hence B's method will be called.
Thanks, PLEASE UPVOTE if helpful
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.