Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 6 What is the output of following program: public class Test { public static void main(String[] args) { B b = new B(2); b.methodAB();

Question 6

What is the output of following program:

public class Test {

public static void main(String[] args) {

B b = new B(2);

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 {

private int num = 0;

public B() {

super();

System.out.println("B's constructor is executed");

}

public B (int n)

{

num = n;

System.out.println("B's constructor is executed");

}

public void methodB() {

System.out.println(num is + num);

System.out.println("methodB is executed");

}

public void methodAB() {

System.out.println("B's methodAB is executed");

}

}

A.

B's constructor is executed

B's methodAB is executed

B.

Compiling time error because both classes A & B have methodAB.

C.

B's constructor is executed

A's methodAB is executed

D.

A's constructor is executed

B's constructor is executed

B's methodAB is executed

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago