Return to site

JAVA CERTIFICATION QUESTION: The Java MapUtility class

· java,ocp

In this scenario, a coworker is writing a framework that enhances work with Java collections.

In particular, the following MapUtility class allows a client to receive the java.util.NoSuchElementException exception

if the key is missing in the map or the value found is null:

However, after sharing the framework within your company, the code’s author starts getting bug reports from colleagues.

What is the problem with this class? Choose one.

A. The java.util.Map interface does not allow null keys, so passing in a null in the get method code throws NullPointerException.

B. The java.util.Map interface does not allow null values, so this code never throws NoSuchElementException.

C. The class may throw UnsupportedOperationException.

D. None of the above.

 

 

 

 

 

·ꓛ uoᴉʇdo sᴉ ɹǝʍsuɐ ʇɔǝɹɹoɔ ǝɥꓕ