Analyze the following code:
```
public class Test {
public static void main(String[] args) {
new B();
}
}
class A {
int i = 7;
public A() {
setI(20);
System.out.println("i from A is " + i);
}
public void setI(int i) {
this.i = 2 * i;
}
}
class B extends A {
public B() {
// 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".
d When invoking new B(), B's superclass A's constructor is invoked first. It invokes setI(20). The setI method in B is used becasue object created is new B(). The setI method in B assigns 3 * 20 to i. So it displays i from A is 60.
You might also like to view...
Which of the following does an administrator need to be aware of when installing a wireless network in a building with multiple floors?
A. Frequency configuration B. SSID naming C. Channel overlap D. Encryption algorithm
Find an equation of a line given the following information. The final answer should be left in slope-intercept form. Passes through the points and
What will be an ideal response?