Answered step by step
Verified Expert Solution
Link Copied!

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(): }

image text in transcribed

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

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

Students also viewed these Databases questions