The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java Coding Interview programming Questions : Java Test on HashMap

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
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
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Java Coding Interview programming Questions : Java Test on HashMap
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
1.What will be the Output of this program.


  1. public class HashMapJavaTricky{
  2.  
  3. public static void main(String[] args) {
  4.  
  5.     HashMap<Integer,String> hm= new HashMap<Integer, String>();  

  6.      hm.put(1, "one");
  7.      hm.put(2, "two");
  8.      hm.put(3, "three");
  9.  
  10.     System.out.println(hm.size()); 
  11.  
  12. for (Integer name: hm.keySet()){
  13.  
  14.    System.out.println(name + " " + hm.get(name)); 
  15.   
  16. }
  17.  
  18. }
  19. }


Click for Output



2.Basics of java programming : Hashmap

  1. public class HashMapJavaTricky{
  2.  
  3. public static void main(String[] args) {
  4.  
  5.     HashMap<Integer,String> hm= new HashMap<Integer, String>();  

  6.      hm.put(1, "one");
  7.      hm.put(2, "two");
  8.      hm.put(3, "three");
  9.  
  10.      hm.put(1, "ONE");
  11.  
  12.     System.out.println(hm.size()); 
  13.  
  14. for (Integer name: hm.keySet()){
  15.  
  16.    System.out.println(name + " " + hm.get(name)); 
  17.   
  18. }
  19.  
  20. }
  21. }


Click for Output




3.Java programming examples: Hashmap

  1. public class HashMapJavaTricky{
  2.  
  3. public static void main(String[] args) {
  4.  
  5.     HashMap<Integer,String> hm= new HashMap<Integer, String>();  

  6.      hm.put(1, "one");
  7.      hm.put(2, "two");
  8.      hm.put(3, "three");
  9.  
  10.      hm.put(1, "ONE");
  11.      hm.put(null,null);
  12.  
  13.     System.out.println(hm.size()); 
  14.  
  15. for (Integer name: hm.keySet()){
  16.  
  17.    System.out.println(name + " " + hm.get(name)); 
  18.   
  19. }
  20.  
  21. }
  22. }


Click for Output




4.Java programming for beginners : HashMap

  1. public class HashMapJavaTricky{
  2.  
  3. public static void main(String[] args) {
  4.  
  5.     HashMap<Integer,String> hm= new HashMap<Integer, String>();  

  6.      hm.put(1, "one");
  7.      hm.put(2, "two");
  8.      hm.put(3, "three");
  9.  
  10.      hm.put(1, "ONE");
  11.      hm.put(null,null);
  12.  
  13.      Integer i=null;
  14.      String str="java programming basics Interview questions";
  15.  
  16.      hm.put(i, str);
  17.  
  18.     System.out.println(hm.size()); 
  19.  
  20. for (Integer name: hm.keySet()){
  21.  
  22.    System.out.println(name + " " + hm.get(name)); 
  23.   
  24. }
  25.  
  26. }
  27. }


Click for Output



Read: Java Coding Interview programming Questions : Java Test on HashMap

Topic: Decrease your Java IDE lagging by fine tuning JVM Garbage Collector Previous Topic   Next Topic Topic: Dear API Designer. Are You Sure, You Want to Return a Primitive?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use