instanceof java
Posts: 576
Nickname: instanceof
Registered: Jan, 2015
instanceof java is a java related one.
Java Coding Interview programming Questions : Java Test on HashMap
Posted: Feb 15, 2016 7:39 AM
Advertisement
1.What will be the Output of this program. public class HashMapJavaTricky{ public static void main(String[] args) { HashMap<Integer,String> hm= new HashMap<Integer, String>(); hm.put(1, "one"); hm.put(2, "two"); hm.put(3, "three"); System.out.println(hm.size()); for (Integer name: hm.keySet()){ System.out.println(name + " " + hm.get(name)); } } } Click for Output
2.Basics of java programming :
Hashmap public class HashMapJavaTricky{ public static void main(String[] args) { HashMap<Integer,String> hm= new HashMap<Integer, String>(); hm.put(1, "one"); hm.put(2, "two"); hm.put(3, "three"); hm.put(1, "ONE"); System.out.println(hm.size()); for (Integer name: hm.keySet()){ System.out.println(name + " " + hm.get(name)); } } }
Click for Output
3. Java programming examples: Hashmap public class HashMapJavaTricky{ public static void main(String[] args) { HashMap<Integer,String> hm= new HashMap<Integer, String>(); hm.put(1, "one"); hm.put(2, "two"); hm.put(3, "three"); hm.put(1, "ONE"); hm.put(null,null); System.out.println(hm.size()); for (Integer name: hm.keySet()){ System.out.println(name + " " + hm.get(name)); } } } Click for Output
4 null null 1 ONE 2 two 3 three 4. Java programming for beginners : HashMap public class HashMapJavaTricky{ public static void main(String[] args) { HashMap<Integer,String> hm= new HashMap<Integer, String>(); hm.put(1, "one"); hm.put(2, "two"); hm.put(3, "three"); hm.put(1, "ONE"); hm.put(null,null); Integer i=null; String str="java programming basics Interview questions"; hm.put(i, str); System.out.println(hm.size()); for (Integer name: hm.keySet()){ System.out.println(name + " " + hm.get(name)); } } } Click for Output
4 null java programming basics Interview questions 1 ONE 2 two 3 three
Read: Java Coding Interview programming Questions : Java Test on HashMap