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 108 times)

CBme

  • Hero Member
  • *****
  • Posts: 548
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 int hashCode() {
return 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 CBme on May 6, 2020

SomethingSomething

  • Sr. Member
  • ****
  • Posts: 323
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




CBme

  • Member
  • Posts: 548
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


adf223

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

 

Did you know?

The oldest recorded age was 122. Madame Jeanne Calment was born in France in 1875 and died in 1997. She was a vegetarian and loved olive oil, port wine, and chocolate.

Did you know?

About 100 new prescription or over-the-counter drugs come into the U.S. market every year.

Did you know?

Opium has influenced much of the world's most popular literature. The following authors were all opium users, of varying degrees: Lewis Carroll, Charles, Dickens, Arthur Conan Doyle, and Oscar Wilde.

Did you know?

The cure for trichomoniasis is easy as long as the patient does not drink alcoholic beverages for 24 hours. Just a single dose of medication is needed to rid the body of the disease. However, without proper precautions, an individual may contract the disease repeatedly. In fact, most people develop trichomoniasis again within three months of their last treatment.

Did you know?

Cucumber slices relieve headaches by tightening blood vessels, reducing blood flow to the area, and relieving pressure.

For a complete list of videos, visit our video library