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 130 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
YES! Correct, THANKS for helping me on my review


kjohnson

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

 

Did you know?

Oxytocin is recommended only for pregnancies that have a medical reason for inducing labor (such as eclampsia) and is not recommended for elective procedures or for making the birthing process more convenient.

Did you know?

For about 100 years, scientists thought that peptic ulcers were caused by stress, spicy food, and alcohol. Later, researchers added stomach acid to the list of causes and began treating ulcers with antacids. Now it is known that peptic ulcers are predominantly caused by Helicobacter pylori, a spiral-shaped bacterium that normally exist in the stomach.

Did you know?

Ether was used widely for surgeries but became less popular because of its flammability and its tendency to cause vomiting. In England, it was quickly replaced by chloroform, but this agent caused many deaths and lost popularity.

Did you know?

The Babylonians wrote numbers in a system that used 60 as the base value rather than the number 10. They did not have a symbol for "zero."

Did you know?

Human stomach acid is strong enough to dissolve small pieces of metal such as razor blades or staples.

For a complete list of videos, visit our video library