1.

What Is The Output Of This Program? 1. Import Java.util.*; 2. Class Maps { 3. Public Static Void Main(string Args[]) { 4. Hashmap Obj = New Hashmap(); 5. Obj.put("a", New Integer(1)); 6. Obj.put("b", New Integer(2)); 7. Obj.put("c", New Integer(3)); 8. System.out.println(obj.get("b")); 9. } 10. }

Answer»

obj.get(“B”) METHOD is used to obtain the VALUE associated with KEY “B”, which is 2.

Output:

$ JAVAC Maps.java
$ java Maps
2

obj.get(“B”) method is used to obtain the value associated with key “B”, which is 2.

Output:

$ javac Maps.java
$ java Maps
2



Discussion

No Comment Found

Related InterviewSolutions