多项选择题

public class Key { 
private long id1; 
private long 1d2; 
// class Key methods 
} 
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()

A. public int hashCode()
B. public boolean equals(Key k)
C. public int compareTo(Object o)
D. public boolean equals(Object o)
E. public boolean compareTo(Key k)


您可能感兴趣的试卷

你可能感兴趣的试题

4.单项选择题

1. import java.util.*; 
2. public class TestSet { 
3. enum Example { ONE, TWO, THREE } 
4. public static void main(String[] args) { 
5. Collection coll = new ArrayList(); 
6. coll.add(Example.THREE); 
7. coll.add(Example.THREE); 
8. coll.add(Example.THREE); 
9. coll.add(Example.TWO); 
10. coll.add(Example.TWO); 
11. coll.add(Example.ONE); 
12. Set set = new HashSet(coll); 
13. } 
14. } 
Which statement is true about the set variable on line 12?() 

A. The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.
B. The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.
C. The set variable contains all six elements from the coil collection, but the order is NOT guaranteed to be preserved.
D. The set variable contains only three elements from the coil collection, but the order is NOT guaranteed to be preserved.

9.多项选择题Which two are true about has-a and is-a relationships?()

A. Inheritance represents an is-a relationship.
B. Inheritance represents a has-a relationship.
C. Interfaces must be used when creating a has-a relationship.
D. Instance variables can be used when creating a has-a relationship.

10.多项选择题Which four are true?()

A. Has-a relationships should never be encapsulated.
B. Has-a relationships should be implemented using inheritance.
C. Has-a relationships can be implemented using instance variables.
D. Is-a relationships can be implemented using the extends keyword.
E. Is-a relationships can be implemented using the implements keyword.
F. An array or a collection can be used to implement a one-to-many has-a relationship.
G. The relationship between Movie and Actress is an example of an is-a relationship.