The method ________ is used to remove all the mappings from a Map.
- clear()
- eraseAll()
- removeAll()
- removeMappings()
In Java, the clear() method is used to remove all the mappings from a Map. It does not remove the map itself but makes it empty, removing all key-value pairs. The other options do not perform this specific function.
Loading...
Related Quiz
- Imagine a scenario where a project utilizes several classes extending a single superclass. If a method in the superclass is modified, how might this impact the subclasses, and what precautions should be taken?
- Which of the following primitive data types has the largest size in memory?
- Why might a programmer choose to use package-private (default) access level over private for a method within a class?
- The method ________ is used to execute SQL for DDL statements using JDBC.
- Which operator can be used to invert the sign of a numeric expression?