Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Analyze the following code: public class Test { public static void main ( String [ ] args ) { new B ( ) ; }

Analyze the following code:
public class Test {
public static void main(String[] args){
new B();
}
}
class A {
int i =7;
public A(){
System.out.println("i from A is "+ i);
}
public void setI(int i){
this.i =2* i;
}
}
class B extends A {
public B(){
setI(20);
// System.out.println("i from B is "+ i);
}
@Override
public void setI(int i){
this.i =3* i;
}
} a.
The constructor of class A is not called.
b.
The constructor of class A is called and it displays "i from A is 7".
c.
The constructor of class A is called and it displays "i from A is 40".
d.
The constructor of class A is called and it displays "i from A is 60".

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

How does inertia welding differ from friction welding?

Answered: 1 week ago