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 122 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
Gracias!


fatboyy09

  • Member
  • Posts: 358
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

The top five reasons that children stay home from school are as follows: colds, stomach flu (gastroenteritis), ear infection (otitis media), pink eye (conjunctivitis), and sore throat.

Did you know?

Drugs are in development that may cure asthma and hay fever once and for all. They target leukotrienes, which are known to cause tightening of the air passages in the lungs and increase mucus productions in nasal passages.

Did you know?

The average office desk has 400 times more bacteria on it than a toilet.

Did you know?

Allergies play a major part in the health of children. The most prevalent childhood allergies are milk, egg, soy, wheat, peanuts, tree nuts, and seafood.

Did you know?

The first-known contraceptive was crocodile dung, used in Egypt in 2000 BC. Condoms were also reportedly used, made of animal bladders or intestines.

For a complete list of videos, visit our video library