Most Asked Java Collection Framework Interview Questions and Answers | Code Decode | Part 2

In this video of code decode we have covered most asked collection framework interview questions
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/udemycourse
Course Description Video :
yt.openinapp.co/dmjvd
Collection Interview Questions part - 1
• Java collections frame...
00:09 How does LinkedList is implemented in Java, is it a Singly or Doubly linked list?
LinkedList in Java is a doubly linked list.
00:37 When to use ArrayList and LinkedList?
LinkedLists are better to use for the update operations whereas
ArrayLists are better to use for the search operations.
02:36 What is the difference between the HashMap, TreeMap and LinkedHashMap?
The next question in collection interview questions and answer is :
06:10 What is a priority queue in Java?
A priority queue in Java is an abstract data type similar to a regular queue or stack data structure but has a special feature called priority associated with each element.
In this queue, a high priority element is served before a low priority element irrespective of their insertion order. The PriorityQueue is based on the priority heap.
The elements of the priority queue are ordered according to the natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used.
07:06 Can you use any class as a Map key?
The class overriding the equals() method must also override the hashCode() method
The class should adhere to the rules associated with equals() and hashCode() for all instances
The class field which is not used in the equals() method should not be used in hashCode() method as well
The best way to use a user-defined key class is by making it immutable. It helps in caching the hashCode() value for better performance. Also if the class is made immutable it will ensure that the hashCode() and equals() are not changing in the future.
09:34 How to make Java ArrayList Read-Only?
We can obtain java ArrayList Read-only by calling the Collections.unmodifiableCollection() method.
When we define an ArrayList as Read-only then we cannot perform any modification in the collection through add(), remove() or set() method.
10:31 How to traverse or loop over a Map in Java
1. Iterating or looping map using Java 5 foreach loop
2. Iterating Map in Java using KeySet Iterator
3. Looping HashMap in Java using EntrySet and Java 5 for loop
4. Iterating HashMap in Java using EntrySet and Java iterator
14:55 How to remove duplicates from ArrayList?
There are two ways to remove duplicates from the ArrayList.
Using HashSet: By using HashSet we can remove the duplicate element from the ArrayList, but it will not then preserve the insertion order.
Using LinkedHashSet: We can also maintain the insertion order by using LinkedHashSet instead of HashSet.
The Process to remove duplicate elements from ArrayList using the LinkedHashSet:
Copy all the elements of ArrayList to LinkedHashSet.
Empty the ArrayList using clear() method, which will remove all the elements from the list.
Now copy all the elements of LinkedHashset to ArrayList.
16:40 How is WeakHashMap differs from other HashMap?
WeakHashMap is a HashMap, with keys that are of a WeakReference type.
An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use, meaning that there is no single Reference that point to that key. When the garbage collection (GC) process discards a key, its entry is effectively removed from the map, even though it is associated with WeakHashMap. i.e Garbage Collector dominates over WeakHashMap.
20:48 What are best practices related to Java Collections Framework
Most Asked Core Java Interview Questions and Answers: • Core Java frequently a...
Advance Java Interview Questions and Answers: • Advance Java Interview...
Java 8 Interview Questions and Answers: • Java 8 Interview Quest...
Hibernate Interview Questions and Answers:
• Hibernate Interview Qu...
Spring Boot Interview Questions and Answers:
• Advance Java Interview...
Angular Playlist: • Angular Course Introdu...
SQL Playlist: • SQL Interview Question...
GIT: • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode: kzread.info?...
LinkedIn : / codedecodeyoutube
Instagram: / codedecode25
#collections #java #codedecode

Пікірлер: 32

  • @anuragpanwar912
    @anuragpanwar9123 ай бұрын

    16:35 for this we can use like that also :-public class Main { public static void main(String[] args) { ArrayList al=new ArrayList(); al.add(1); al.add(2); al.add(3); al.add(3); Set set=new HashSet(); Iterator listIterator = al.iterator(); while (listIterator.hasNext()) { Integer next = listIterator.next(); if(!set.add(next)) { listIterator.remove(); } } set.clear(); System.out.println(al); System.out.println(set); } }

  • @utkarshshukla2448
    @utkarshshukla2448 Жыл бұрын

    Thank you mam , can you please make videos on trees and graph also like one question on graph was asked in an interview -> there is 2 array given check if it is cyclic graph or not .

  • @ArpitSingh-wp6yx
    @ArpitSingh-wp6yx Жыл бұрын

    Make a complete single vdo covering imp interview Questions on Oracle sql ...love your way of explaining the things in clear and concise way ❤️😊

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure Thanks Arpit 👍🙂

  • @arpitsik4649
    @arpitsik4649 Жыл бұрын

    pure Gold🔥 Please being more sessions on collection

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure Arpit 🙂🙂

  • @dssomething8516
    @dssomething8516 Жыл бұрын

    Your explanation is so good, want to learn java 17 If you can make it's so helpful to us

  • @AnilKumar-fb8jg
    @AnilKumar-fb8jg Жыл бұрын

    I was about to request this video from you and you posted it. Thank you very much. I've been following for a quite a long time now, really appreciate the efforts you put in. Great content. Waiting for more🙂

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Thanks to u guys only Anil. Someone posted a comment for second part that's why we created another. You guys only gives us directions 🙏🙏👍👍

  • @AnilKumar-fb8jg

    @AnilKumar-fb8jg

    Жыл бұрын

    @@CodeDecode Also one more thing, It would be great if you create a seperate playlist for these collection related videos. It makes our life easy, Thank you. Ignore if there is already a playlist and If I missed it somehow.

  • @husenfakir7244
    @husenfakir7244 Жыл бұрын

    Mam ur teaching is fabulous Make video on hibernate in deep And spring and springboot ,rest api

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure though we have them all in our playlist. You need links to all??🙂

  • @sonalgupta7083
    @sonalgupta70835 ай бұрын

    For treemap, do we have to implement comparator or comparable in the class (which is going to be key)?

  • @saikaladhar7607
    @saikaladhar7607 Жыл бұрын

    Nice one 💥

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Thanks

  • @ganeshkumarroyal5416
    @ganeshkumarroyal5416 Жыл бұрын

    The way you explained is simply super can you please make a single vedio and complete vedio for java 8 feactures instead of different different vedios make it single vedio

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure thanks 🙂🙂

  • @arpitsik4649
    @arpitsik4649 Жыл бұрын

    Firstly thanks for the videos. It helps immensely. Just wantrd to say, if you can increse the frequency of your videos it will help much.

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure Arpit. It's just we all work in IT and it's really difficult to fetch time between sprints 🙂. Sorry for inconvenience. We will try to be more frequent. 👍

  • @arpitsik4649

    @arpitsik4649

    Жыл бұрын

    @@CodeDecode Completely agree. Dont make us feel bad by apologizing. Just mark my words as a request. You are already doing your best. ❤️💯

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Thanks a lot Arpit🙏thanks for understanding 👍🙂

  • @dhrupeshpokiya9541
    @dhrupeshpokiya95412 ай бұрын

    LinkedHashMap preserves the insertion order right .. while iterating the keyset or entryset then how does it maintain the insertion order?

  • @start1learn-n171
    @start1learn-n1714 ай бұрын

    Tq

  • @CodeDecode

    @CodeDecode

    4 ай бұрын

    Welcome

  • @pandeyperfect8292
    @pandeyperfect82928 ай бұрын

    nice

  • @CodeDecode

    @CodeDecode

    8 ай бұрын

    Thanks

  • @hamednikbakht9708
    @hamednikbakht9708 Жыл бұрын

    goood

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Thanks 🙂

  • @raghunathgurram
    @raghunathgurram Жыл бұрын

    Can you please add Java 11 features?

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure we will cover java 11 feature soon

  • @dssomething8516
    @dssomething8516 Жыл бұрын

    Can you make some videos for java 17

  • @CodeDecode

    @CodeDecode

    Жыл бұрын

    Sure 👍👍

Келесі