What Will Be The Output Of The Following Java Codep Pre #865
What will be the output of the following Java code?</p> <pre><code class="language-java"> class A { public void X() { System.out.print("Bangalore-"); } } class B extends A { public void Y() { System.out.print("560102"); } } class C extends A { public void Z() { System.out.print("560108"); } } public class Details { public static void main(String[] args) { B obj1 = new B(); C obj2 = new C(); obj2.X(); obj2.Z(); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Inheritance (Using Java) - Hierarchical Inheritance - Quiz No.2.
What will be the output of the following Java code?
class A { public void X() { System.out.print("Bangalore-"); } } class B extends A { public void Y() { System.out.print("560102"); } } class C extends A { public void Z() { System.out.print("560108"); } } public class Details { public static void main(String[] args) { B obj1 = new B(); C obj2 = new C(); obj2.X(); obj2.Z(); } }
560102
Bangalore-560102
Bangalore-560108
560108