Java OCA OCP Practice Question 2808

Question

What is the output of the following method if props contains {veggies=Bunny, meat=velociraptor}?

private static void print(Properties props) { 
   System.out.println(props.get("veggies", "none") 
       + " " + props.get("omni", "none")); 
} 
  • A. Bunny none
  • B. Bunny null
  • C. none none
  • D. none null
  • E. The code does not compile.
  • F. A runtime exception is thrown.


E.

Note

The Properties class defines a get() method that does not allow for a default value.

It also has a getProperty() method, which returns the default value if the key is not provided.




PreviousNext

Related