properties of string makes it perfect candidate for Map key? choose two (a) Final (b) Serialize (c) Clone (d) Immutable
Answers
Answered by
0
Answer:
(b) Serialize and (d) Immutable
Explanation:
Have a nice day :)
Answered by
1
Option a) Final and d) Immutable
properties of string makes it perfect candidate for Map key
- In Java, a map is a collection that holds key-value pairs. This's keys can't be null, and each key can only lead to one value. It is represented by the Java.util package's Map interface. There are numerous classes that offer this interface's implementation.
- A class that implements the Map interface is called HashMap. Its foundation is the hash table. It accepts null keys and null values.
- In a nutshell, the HashMap object allows you to store key-value pairs. Once you've done that, you may access the values of the corresponding keys, but the key values we utilise need to be distinct.Final denotes that you can still modify an object's state even while you can't alter its reference to point to another reference or another object (using setter methods e.g). While an immutable object's real value cannot be changed, its reference to another object can be altered
- Because the string is immutable, we can change the reference to the object but not the object itself. The string is marked as final to prevent further extensions that would compromise its immutability.
#SPJ2
Similar questions