2) What will be the output of the following program?
package navmap; import java.util.HashMap; import java.util.NavigableMap; import java.util.TreeMap; public class Ques01 { public static void main(String[] args) { NavigableMap<String, String> colors = new HashMap<String, String>(); colors.put("RED", "Red"); colors.put("BLUE", "Blue"); System.out.println(colors.get("BLUE")); } }
- The program will output ‘null’.
- The program will return ‘Blue’.
- The program won’t compile because of compilation errors.
- The program will throw a run-time exception.
Answer
2) c.
The program won’t compile since the class HashMap doesn’t implement the NavigableMap interface.