Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What is the output of following program: public class Test{ public static void main(String[] args) { A a = new A(): a method B(): }
What is the output of following program: public class Test{ public static void main(String[] args) { A a = new A(): a method B(): } } class A{ public A(){ System out println("A's constructor is executed"): } public void method(){ System out printin ("methodA is executed"): } public void methodAB(){ System out printin ("As methodAB is executed"): } } class B extends A { private int num = 0: public B (){ super(): System out printin ("B's constructor is executed"): } public B (int n) { num = n: System out printin("B's constructor is executed"): } public void method B(){ System out. println("num is"+ num): System.out.println("methodB is executed"): } public void methodAB(){ System.out println ("B's methodAB is executed"): A's constructor is executed num is 0 method B is executed A's constructor is executed methodA is executed Compiling time error because "methodB" is not defined in Class A
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