Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago