Question: Java expert please help me QUESTION 34 Which of the following best describes Sally? 1 2 public class Sally { 3 4 private double data;
Java expert please help me
QUESTION 34
Which of the following best describes Sally?
1
2 public class Sally { 3
4 private double data;
5
6 public Sally(double d) { 7 data = d;8 }
9
10 public int hashCode() { 11 final int prime = 31;
12 int result = 1;
13 result = prime * result;
14 return result;15 }
16
17 public boolean equals(Object obj) { 18 if (this == obj)
19 return true;
20 if (obj == null)
21 return false;
22 if (!(obj instanceof Sally))
23 return false;
24 Sally other = (Sally) obj;
25 if (Math.abs(data - other.data) < .00001)
26 return true;
27 return false;
28 }
29 }
| A - Sally cannot be used in a HashSet because it is not serializable | ||
| B - Sally will not compile because to override equals, the signature must be boolean equals(Sally obj) | ||
| C - Sally should not be used in a HashSet because equal objects may have different hash values. | ||
| D - Sally can be used in a HashSet, but the HashSet will perform poorly because of collisions |
QUESTION 35
If no locale is explicitly supplied for user messages, the system uses messages associated with US English.
True
False
QUESTION 36
You should always invoke the unlock method in the finally clause.
| true | ||
| false |
QUESTION 37
Under what conditions are locks unnecessary for multi-threaded programs?
| A- when the threads are different classes | ||
| B- when the threads do not share data | ||
| C - when the shared data only has a single method | ||
| D - when the threads are all of the same class |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
