35.8k views
0 votes
What is the signature of a Map method that finds and returns a value in the Map?

a) V findValue(K key)
b) V get(K key)
c) K findKey(V value)
d) K locate(V value)

1 Answer

4 votes

Final answer:

The signature of a Map method that finds and returns a value in the Map is V get(K key).

Step-by-step explanation:

The correct signature for a Map method that finds and returns a value in the Map is V get(K key). This method takes a key as a parameter and returns the corresponding value from the Map. Here's an example:

Map<String, Integer> map = new HashMap<>();
map.put("apple", 4);
int value = map.get("apple");
// value will be 4

User Sam Chats
by
7.3k points