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

Author Question: What is the output for the following code?import java.util.*;public class Test { public static void ... (Read 118 times)

bobbie

  • Hero Member
  • *****
  • Posts: 592
What is the output for the following code?

import java.util.*;
public class Test {
public static void main(String[] args) {
Set set = new HashSet();
set.add(new A());
set.add(new A());
set.add(new A());
set.add(new A());
System.out.println(set);
}
}

class A {
int r = 1;

public String toString() {
return r + "";
}

public boolean equals(Object o) {
return this.r == ((A)o).r;
}
}

◦ [1, 1, 1]
◦ [1, 1, 1, 1]
◦ [1, 1]
◦ [1]


Related Topics

Need homework help now?

Ask unlimited questions for free

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

katheyjon

  • Sr. Member
  • ****
  • Posts: 331
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 39% of students answer this correctly




bobbie

  • Member
  • Posts: 592
Reply 2 on: May 6, 2020
:D TYSM


cici

  • Member
  • Posts: 325
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

The largest baby ever born weighed more than 23 pounds but died just 11 hours after his birth in 1879. The largest surviving baby was born in October 2009 in Sumatra, Indonesia, and weighed an astounding 19.2 pounds at birth.

Did you know?

Amphetamine poisoning can cause intravascular coagulation, circulatory collapse, rhabdomyolysis, ischemic colitis, acute psychosis, hyperthermia, respiratory distress syndrome, and pericarditis.

Did you know?

The average older adult in the United States takes five prescription drugs per day. Half of these drugs contain a sedative. Alcohol should therefore be avoided by most senior citizens because of the dangerous interactions between alcohol and sedatives.

Did you know?

As many as 28% of hospitalized patients requiring mechanical ventilators to help them breathe (for more than 48 hours) will develop ventilator-associated pneumonia. Current therapy involves intravenous antibiotics, but new antibiotics that can be inhaled (and more directly treat the infection) are being developed.

Did you know?

Medications that are definitely not safe to take when breastfeeding include radioactive drugs, antimetabolites, some cancer (chemotherapy) agents, bromocriptine, ergotamine, methotrexate, and cyclosporine.

For a complete list of videos, visit our video library