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 127 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
Great answer, keep it coming :)


Laurenleakan

  • Member
  • Posts: 309
Reply 3 on: Yesterday
Gracias!

 

Did you know?

Symptoms of kidney problems include a loss of appetite, back pain (which may be sudden and intense), chills, abdominal pain, fluid retention, nausea, the urge to urinate, vomiting, and fever.

Did you know?

Approximately 25% of all reported medication errors result from some kind of name confusion.

Did you know?

Hip fractures are the most serious consequences of osteoporosis. The incidence of hip fractures increases with each decade among patients in their 60s to patients in their 90s for both women and men of all populations. Men and women older than 80 years of age show the highest incidence of hip fractures.

Did you know?

Alzheimer's disease affects only about 10% of people older than 65 years of age. Most forms of decreased mental function and dementia are caused by disuse (letting the mind get lazy).

Did you know?

After a vasectomy, it takes about 12 ejaculations to clear out sperm that were already beyond the blocked area.

For a complete list of videos, visit our video library