Question
QUESTION 25 What is the output of following program: public class Test { public static void main(String[] args) { B b = new B(); b.methodA();
QUESTION 25
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.println("A's constructor is executed");
}
public void methodA() {
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's methodAB is executed");
}
}
| A. | B's constructor is executed methodA is executed methodB is executed B's methodAB is executed |
| B. | Compiling time error because B does not have methodA. |
| C. | A's constructor is executed B's constructor is executed methodA is executed methodB is executed B's methodAB is executed |
| D. | Compiling time error because super is not defined. |
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