Question: .Show the output of the code below: public class OOPExercises { static int a = 555; public static void main(String[] args) { A objA =

.Show the output of the code below:

public class OOPExercises {

static int a = 555;

public static void main(String[] args) {

A objA = new A();

B objB1 = new B();

A objB2 = new B();

C objC1 = new C();

B objC2 = new C();

A objC3 = new C();

objA.display();

objB1.display();

objB2.display();

objC1.display();

objC2.display();

objC3.display(); }

} Output:

public class A {

int a = 100;

public void display() {

System.out.printf("a in A = %d ", a);

}

} //class A

public class B extends A{

private int a = 123;

public void display() {

System.out.printf("a in B = %d ", a);

}

} //class B

public class C extends B {

private int a = 543;

public void display() {

System.out.printf("a in C = %d ", a);

}

} //class C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure here is the output of the code a in A 100 a in B 123 a in B 123 a in C 543 a in C 543 a in C 54... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!