What is the output of following program: public class Test { public static void
ID: 3852016 • Letter: W
Question
What is the output of following program: public class Test { public static void main|String[] args) { B b=new B(): b.methodA(): b.methodB() b.methodAB(): } } class A { public A() { System.out.printin["A's constructor is executed"]: } public void method[]{ System.out.println ("methodA is executed"): } public void methodAB() { System.out.println("A's methodAB is executed"): } } class B extends A { public B() { super(): System.out.println["B's constructor is executed"]: } public void methodB() { System.out.println("methodB is executed"): } public void methodAB() { System.out.println("B is methodAB is executed"): } } A. A's constructor is executed B's constructor is executed methodA is executed methodBis executed B's methodAB is executed B Compiling time error because "super" is not defined. C. Compiling time error because B does not have mathodA D. B's constructor is executed methodA is executed methodBis executed B's methodAB is executedExplanation / Answer
A is the answer the class is not static the b constructor is executed then only the method A is executed and the method B is executed lastly method AB is then executed
option D is not because the object is called at the run time the object b is first to be compiled
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.