Scjp题目Question 174Click the Exhibit button.1.import java.uti
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 18:25:25
Scjp题目
Question 174
Click the Exhibit button.
1.import java.util.*;
2.class KeyMaster {
3.public int i;
4.public KeyMaster(int i) { this.i = i; }
5.public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
6.public int hashCode() { return i; }
7.}
8.public class MapIt {
9.public static void main(String[] args) {
10.Set set = new HashSet();
11.KeyMaster k1 = new KeyMaster(1);
12.KeyMaster k2 = new KeyMaster(2);
13.set.add(k1); set.add(k1);
14.set.add(k2); set.add(k2);
15.System.out.print(set.size() + °:±
16.k2.i = 1;
17.System.out.print(set.size() + °:±
18.set.remove(k1);
19.System.out.print(set.size() + °:±
20.set.remove(k2);
21.System.out.print(set.size());
22.}
23.}
What is the result?
A.4:4:2:2
B.4:4:3:2
C.2:2:1:0
D.2:2:0:0
E.2:1:0:0
F.2:2:1:1
G.4:3:2:1
Answer:F
为什么不选c呢?
Question 174
Click the Exhibit button.
1.import java.util.*;
2.class KeyMaster {
3.public int i;
4.public KeyMaster(int i) { this.i = i; }
5.public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
6.public int hashCode() { return i; }
7.}
8.public class MapIt {
9.public static void main(String[] args) {
10.Set set = new HashSet();
11.KeyMaster k1 = new KeyMaster(1);
12.KeyMaster k2 = new KeyMaster(2);
13.set.add(k1); set.add(k1);
14.set.add(k2); set.add(k2);
15.System.out.print(set.size() + °:±
16.k2.i = 1;
17.System.out.print(set.size() + °:±
18.set.remove(k1);
19.System.out.print(set.size() + °:±
20.set.remove(k2);
21.System.out.print(set.size());
22.}
23.}
What is the result?
A.4:4:2:2
B.4:4:3:2
C.2:2:1:0
D.2:2:0:0
E.2:1:0:0
F.2:2:1:1
G.4:3:2:1
Answer:F
为什么不选c呢?
因为现在的k2和加入进去的k2不是同一个,所以你根本无法去掉原来那个.
Scjp题目Question 174Click the Exhibit button.1.import java.uti
自动 英语 1.On the Windows taskbar,click the Start button,and th
英语翻译1.Start Windows XP2.Click the Start button; point to Set
java 中import java.sql.Connection 报错:The import java.sql.Conn
The import java.awt is never used
click the following button to confirm your membership regist
英语翻译QUESTION 123Refer to the exhibit.Switch port FastEtherne
import java.awt.*,我在MyEclipse里面写下后,下面提示 The import java.awt
import javax.swing.*; import java.awt.*; import java.awt.eve
import java.awt.*; import java.awt.event.*; import javax.swi
import java.util.
import java.io.IOException;