What Will Be The Output Of The Following Java Codep Pre #861

What will be the output of the following Java code?</p> <pre><code class="language-java"> final class A { int a; A() { a=5; } } class B extends A { int a; B() { A obj = new A(); a = obj.a; } } class C extends A { int a; C() { A obj = new A(); a = obj.a; } } class D extends A { int a; D() { A obj = new A(); a = obj.a; } } public class Hierarchy { public static void main(String[] args) { B obj1 = new B(); C obj2 = new C(); D obj3 = new D(); A obj = new B(); System.out.println(obj.a); } }</code></pre>

Online Quiz 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.1.


Similar question(s) are as followings:



Online Quizzes of gs111 OOP Object Oriented Programming Java

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background