#15 - Top 20 HashMap Interview Questions in Java || By Naveen AutomationLabs

แชร์
ฝัง

ความคิดเห็น • 55

  • @ankeshkumar9120
    @ankeshkumar9120 3 ปีที่แล้ว +21

    Well this is the one which was very much needed.before it started i had handful of questions,but believe me it miraculously clarified all of my doubts. Thanks a lot Naveen🙏 you deserve respect...❤️

    • @SarangHoley
      @SarangHoley 3 ปีที่แล้ว +2

      Yes Naveen had earned the respect by giving very good content & with correct direction to the community, he is best always 😊👍

  • @bkumarj6450
    @bkumarj6450 3 ปีที่แล้ว +2

    I am following Naveen from 10k subscribers and he helped me a lot in my automation career...now the count is growing hope it will reach to an infinite loop...

  • @kunalsinha5942
    @kunalsinha5942 3 ปีที่แล้ว +4

    Naveen - Q no : 10 - It can store multiple duplicate values as long as keys are different..

  • @prasadnangarale3457
    @prasadnangarale3457 2 ปีที่แล้ว +2

    Your teaching is very very nice...realy from my heart ..thank you ,thank you, thank you...I found your channel firstly at javaMCAP course there are your vedios for collection framework... Great teaching🙏🏻👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻💞💞💞

  • @mysticalprodigy720
    @mysticalprodigy720 3 ปีที่แล้ว

    Naveen -you are simply superb, in one word all I can say is you have solved the pain of million automation associates .

  • @sureshgarine
    @sureshgarine 3 ปีที่แล้ว +2

    This is really useful and much needed. Thanks for your service to the community.

  • @ABAutomationHub
    @ABAutomationHub ปีที่แล้ว +1

    Excellent explanation as always. Thanks for creating this video. This is very much needed!

  • @shilpashravge5393
    @shilpashravge5393 ปีที่แล้ว

    Perfectly summarized. Appreciate your time and efforts !

  • @palspal2329
    @palspal2329 3 ปีที่แล้ว +1

    Thanks sir for making such greatly needed topic wise videos

  • @santoshkpl2088
    @santoshkpl2088 3 ปีที่แล้ว +1

    Thank you so much for all Hashmap videos sir and happy kannada rajyotsava..

  • @ARCHIT980
    @ARCHIT980 3 ปีที่แล้ว +3

    Hi Naveen
    Thanks for the amazing video.
    In question 10 I have a doubt: We can store duplicate value in Java HashMap:
    Corresponding to different keys we can have the same values.
    for e.g
    hm.put("Archit",1)
    hm.put("Naveen",1)

    • @ARCHIT980
      @ARCHIT980 3 ปีที่แล้ว +1

      Also in Question 21
      When two keys are having the same hascode?
      Yes, obviously the Collison will happen.
      But after it will check using equals() method whether the two keys are same or not. if not same then it will create a node in the particular index of the bucket else it will override the value.
      @Naveen please correct me if am wrong.

    • @AmitKumar-qh4ow
      @AmitKumar-qh4ow 3 ปีที่แล้ว

      @@ARCHIT980 you are right.

  • @hiteshdarji9925
    @hiteshdarji9925 10 หลายเดือนก่อน

    Awsome video. One query Navin bhai what is multi threading how its performing in java and impact on hashmap value?

  • @jeyhunaliyev1765
    @jeyhunaliyev1765 3 ปีที่แล้ว +1

    Awesome i was waiting for this
    Thank you very much for your help

  • @rajatagrawal7016
    @rajatagrawal7016 หลายเดือนก่อน +1

    thanks a lot

  • @ishabiswas4556
    @ishabiswas4556 3 ปีที่แล้ว

    Very Informative
    Thanks for sharing 👍
    Really appreciate your efforts

  • @11223a3b
    @11223a3b 2 ปีที่แล้ว +1

    Wonderful video ☺️

  • @daisyd4172
    @daisyd4172 2 ปีที่แล้ว +1

    💛

  • @artimandale8286
    @artimandale8286 5 หลายเดือนก่อน

    Simply amazing 👌

  • @minigupta6478
    @minigupta6478 ปีที่แล้ว

    Appreciated Thanks for creating this video

  • @parulgarg7429
    @parulgarg7429 3 ปีที่แล้ว +1

    Hi Naveen , every concept is very well explained. Can you please include this question as well and explain :->what if we don't override the hashcode() /equals() method in our custom classes. thx

    • @AmitKumar-qh4ow
      @AmitKumar-qh4ow 3 ปีที่แล้ว +1

      if we will not override hashCode() method in in our custom class then default implementation of hashCode() will be called which is present in Object class, we will get a unique number for every object of custom class whether two objects contain same info like id and name are same e.g Employee emp1=new Employee(101, "Naveen"); Employee emp2(101,"Naveen"); there are two object emp1 and emp2 having same id and name, still we will get different hashCode() for every object, by using int hashCode Value1=emp1.hashCode(); System.out.println(hashCodeValue1) and using int hashCodeValue2=emp1.hashCode(); System.out.println(hashCodeValue2); we will get different hashcode value for both objects if you we will not override hashCode() method but if we will override hashCode() method based upon these two attribute id and name, we will get same hashcode value for two objects having same info (means we are putting same employee info two times) like above where id and name is same.

  • @puneetsaneja3007
    @puneetsaneja3007 3 ปีที่แล้ว +1

    On what basis binary tree decide what to store left and what to store on right ? Is it by hashcode value ?

  • @thunikilokesh1280
    @thunikilokesh1280 3 ปีที่แล้ว +1

    Thank you so much for the collections
    Why dont you try multithreading and spring boot?

  • @jugautomation3102
    @jugautomation3102 3 ปีที่แล้ว

    Great Questions Sir. Hats off.

  • @dystopianNinja1289
    @dystopianNinja1289 3 ปีที่แล้ว

    Amazing video. Thank you Naveen

  • @healthbeautytips6438
    @healthbeautytips6438 3 ปีที่แล้ว +1

    Thanks Naveen for such a good content

  • @sreenivasl221
    @sreenivasl221 3 ปีที่แล้ว

    Very helpful your tutorials, Thank you sir!!!

  • @ajaypaul_dancer
    @ajaypaul_dancer 2 ปีที่แล้ว

    Superb

  • @danceayush8128
    @danceayush8128 3 ปีที่แล้ว

    Great explanation 👍

  • @travelandspiritual
    @travelandspiritual 3 ปีที่แล้ว +1

    Congrats for 132 K Subscribers in your channel .

  • @vivekkeshari6896
    @vivekkeshari6896 3 ปีที่แล้ว

    🙏🙏🙏🙏 great effort in creating this ...👍👍👍👍👍👍👍👍 thanks Naveen

  • @vijaythavva3822
    @vijaythavva3822 3 ปีที่แล้ว

    When we trying to add duplicate key with same value or new value , it will override with new value. Here my question is what happens to that old value , is it stored in somewhere or is it garbage collected ?
    i was faced this question in an interview.

  • @pa1gupta
    @pa1gupta 3 ปีที่แล้ว

    Is threshold value 8 to convert from linkedlist to balanced tree? I see at 8 it will reorganize by increasing the size of hashmap, at 64 it will convert to tree. I see value Min_treeify = 64. Also can you explain at what threshold it will convert back to linkedlist from tree.

  • @solankijigar11
    @solankijigar11 3 ปีที่แล้ว

    Great job......

  • @harithasri8372
    @harithasri8372 2 ปีที่แล้ว

    If HashMap internally uses Hashtable, then how come it is accepting null key? because hashtable do not allow nulll values. My doubt is while inserting values inside hashmap, where they will get inserted? in hashtable or at that index of hashtable new linked is created?and first element is added in that list?

  • @roopadolli1910
    @roopadolli1910 3 ปีที่แล้ว

    Nice Naveen.. 🙏

  • @juhiagarwal7682
    @juhiagarwal7682 3 ปีที่แล้ว

    Thank you Naveen for making such informative videos. I have a confusion regarding keys returning same hashcode, if it happens how will get method return right value for corresponding key as hashcode is stored in node values to perform equals method, I think its index value which is returned same.Correct me if I am wrong.

    • @shankarpk89
      @shankarpk89 3 ปีที่แล้ว +1

      hashcode = get(key) - internally the hashcode of this key is calculated then this hashcode is passed as an argument to hash function
      and then this hash value is passed to indexFor method which calculates the index/bucket/node.
      Then the equals method is invoked which checks whether the key passed matches with the key present at that particular node if the key matches then the value corresponding to the key is returned but if the key does not match which could be the case when multiple keys have the same hashcode i.e. collision case in this case at the same index we have multiple nodes in which object is stored as a linked list. So if the key does not match with the 1st key present at that node then the same operation is repeated until the key matches.

  • @RohitSingh-br3xd
    @RohitSingh-br3xd 3 ปีที่แล้ว

    Hi Naveen, what if we want to get old value for duplicate keys? Is there any way we can get old value instead of the latest?

  • @amritasharma5390
    @amritasharma5390 3 ปีที่แล้ว

    Thank you so much 👍

  • @priyankabakshi9765
    @priyankabakshi9765 3 ปีที่แล้ว

    Hi Naveen, Why equals and hashcode implementation is required for the key and value both if this is needed only for the key..

    • @AmitKumar-qh4ow
      @AmitKumar-qh4ow 3 ปีที่แล้ว

      hashcode and equals methods implementation is required for key not for value.

  • @nandhinimathivanan3998
    @nandhinimathivanan3998 3 ปีที่แล้ว

    In linked hashmap collision occurs ah Naveen

  • @kumargaurav4362
    @kumargaurav4362 3 ปีที่แล้ว

    Sir, could you please clear the concepts of IO ad NIO package in Java.
    It would be very helpful.

  • @nikhildsouza8905
    @nikhildsouza8905 9 หลายเดือนก่อน

    Just FYI , Answer for 10 ) one is Yes , we can have duplicate values with different keys

  • @nityaranjan6714
    @nityaranjan6714 ปีที่แล้ว

    Can you sort HashMap in java? I feel answer is yes. As we can sort it according to keys or values also. Like below for sort it accordingly to keys.
    public class SortedHashMap {
    public static void main(String[] args) {

    HashMap hm = new HashMap();
    hm.put(2, "B");
    hm.put(1, "A");
    hm.put(4, "D");
    hm.put(3, "C");

    Map sortedMap = hm.entrySet().stream().sorted((a,b) ->a.getKey().compareTo(b.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue,(e1,e2) ->e1));

    System.out.println(sortedMap);
    }
    }