This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following code:public class Test { public static void main(String[] args) {new B(); ... (Read 37 times)

cartlidgeashley

  • Hero Member
  • *****
  • Posts: 572
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);
}
 
public void setI(int i) {
this.i = 3 * i;
}
}

◦ The constructor of class A is called and it displays "i from A is 40".
◦ The constructor of class A is called and it displays "i from A is 7".
◦ The constructor of class A is called and it displays "i from A is 60".
◦ The constructor of class A is not called.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by cartlidgeashley on May 6, 2020

lcapri7

  • Sr. Member
  • ****
  • Posts: 350
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




cartlidgeashley

  • Member
  • Posts: 572
Reply 2 on: May 6, 2020
Wow, this really help


scottmt

  • Member
  • Posts: 322
Reply 3 on: Yesterday
Excellent

 

Did you know?

A seasonal flu vaccine is the best way to reduce the chances you will get seasonal influenza and spread it to others.

Did you know?

Dogs have been used in studies to detect various cancers in human subjects. They have been trained to sniff breath samples from humans that were collected by having them breathe into special tubes. These people included 55 lung cancer patients, 31 breast cancer patients, and 83 cancer-free patients. The dogs detected 54 of the 55 lung cancer patients as having cancer, detected 28 of the 31 breast cancer patients, and gave only three false-positive results (detecting cancer in people who didn't have it).

Did you know?

For high blood pressure (hypertension), a new class of drug, called a vasopeptidase blocker (inhibitor), has been developed. It decreases blood pressure by simultaneously dilating the peripheral arteries and increasing the body's loss of salt.

Did you know?

Over time, chronic hepatitis B virus and hepatitis C virus infections can progress to advanced liver disease, liver failure, and hepatocellular carcinoma. Unlike other forms, more than 80% of hepatitis C infections become chronic and lead to liver disease. When combined with hepatitis B, hepatitis C now accounts for 75% percent of all cases of liver disease around the world. Liver failure caused by hepatitis C is now leading cause of liver transplants in the United States.

Did you know?

Vaccines prevent between 2.5 and 4 million deaths every year.

For a complete list of videos, visit our video library