Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9. What would be the output of the following code: class Test Demo public static void main(String args[X Test1 t1 = new Test1); Test2 t2
9. What would be the output of the following code: class Test Demo public static void main(String args[X Test1 t1 = new Test1); Test2 t2 = new Test21); Test3 t3 = new Test3(); class Test1 { private String str = "Test1"; public void showme System.out.println(str); } } class Test2 extends Test1 private String str = "Test2": public void showme System.out.println(str); } } t1 = t2; t1.showmel); t1 = t3; t1. showmel); t2 = t3; t2.showme(): } class Test3 extends Test2 private String str = "Test3"; public void showme() System.out.println(str); 10. What would be the output of the following program: class ExtendedShow extends Super Show String str = "SubClass"; public void show() { System.out.println("Sub. Show: " + str); ) Class Super Show String str = "SuperClass"; public void show() { System.out.println("Super.Show: + str); } } public class ExtensionDemo public static void main(String args[]) { ExtendedShow ext = new ExtendedShow(); SuperShow sup = ext; sup.show(); ext.show(); System.out.println("sup. str: System.out.println("sub.str: + sup.str); + ext.str); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started