Java 8 Arrays Programming Interview Questions and Answers for freshers and experienced | Code Decode

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ก.ค. 2024
  • Welcome to Code Decode, your go-to channel for mastering Java 8 coding interview questions and arrays. In this video, we dive deep into the trickiest Java 8 coding interview questions related to arrays, providing comprehensive explanations and step-by-step solutions.
    Udemy Course of Code Decode on Microservice k8s AWS CICD link:
    openinapp.co/udemycourse
    Course Description Video :
    yt.openinapp.co/dmjvd
    Here are some of the key questions we cover:
    Finding the second smallest element in an array: This question tests your ability to work with arrays and apply Java 8's features effectively. It assesses your understanding of stream operations, sorting, and filtering techniques. Mastering this question enhances your problem-solving skills and demonstrates your grasp of Java 8's functional programming capabilities.
    Finding common elements between two arrays: This question challenges your proficiency in array manipulation and stream processing. It evaluates your ability to leverage Java 8's stream API to efficiently identify shared elements. Excelling in this question showcases your understanding of advanced array operations and stream filtering techniques.
    Reversing an array of integers in-place: This question assesses your knowledge of array manipulation and in-place algorithms. By utilizing Java 8's features, you showcase your ability to reverse an array efficiently without creating a new one. Demonstrating proficiency in this question highlights your understanding of memory optimization and array traversal techniques.
    Finding the length of the longest string in an array: This question evaluates your string manipulation skills using Java 8's stream operations. It tests your ability to combine stream filtering, mapping, and reduction to obtain the length of the longest string. Excelling in this question showcases your expertise in working with string arrays and stream transformations.
    Mastering these Java 8 coding interview questions not only helps you excel in technical interviews but also enhances your overall programming skills. These questions cover essential concepts, such as array manipulation, stream processing, and functional programming, which are widely used in Java development.
    Code Decode's comprehensive explanations and step-by-step solutions empower you to understand the underlying concepts and apply them effectively. By practicing these questions, you'll gain confidence in your Java 8 skills and increase your chances of success in coding interviews.
    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: th-cam.com/users/CodeDecode?...
    LinkedIn: / codedecodeyoutube
    Instagram: / codedecode25
    #java #interviewquestions #codedecode

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

  • @RaushanKumar-rd7we
    @RaushanKumar-rd7we ปีที่แล้ว +5

    Sister, for Q2. common in two Array, the output is not correct if elements are not distinct in array1. so I think need to add: distinct() as well.
    Now output correct:
    public class Intersection {
    public static void main(String[] args) {
    int[] arr1 = {1,2,3,4,4,5};
    int[] arr2 = {4, 4,5,6, 7};
    findIntersection(arr1, arr2);
    }
    public static void findIntersection(int[] arr1, int[] arr2){
    List intersection = Arrays.stream(arr1).distinct().filter(i-> Arrays.stream(arr2).anyMatch(j-> j == i)).boxed().toList();
    System.out.println(intersection);
    }
    }

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

      Correct Raushan 👍👍 that edge case scenario is left to be covered like we did in first question 👏👏

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

    wow the first one, I would only sort the array and do a "arr[1]" as an answer, but using stream gives a nice touch to it!!

  • @deepalimalviya6387
    @deepalimalviya6387 6 หลายเดือนก่อน +2

    Thanks for creating such videos, would you please create a video continuation of this? This will be very helpful.

  • @argonechaks9850
    @argonechaks9850 ปีที่แล้ว +6

    Yes we need more such questions covered

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

      Sure 😊👍

    • @mohanvs-msv
      @mohanvs-msv ปีที่แล้ว

      ​@@CodeDecodeYes we need more problems like this...!!

  • @bhoslegovind9644
    @bhoslegovind9644 10 หลายเดือนก่อน +2

    Thanks mam for provides us such a important content..We will waiting for next part of that video 🤗🎉

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

      👍😊

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

    Love to watch ur content. It will be more helpful if u provide ur source code for same

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

    Love you for this video 👌👌👌 what a video 👌👌 waiting for next part

  • @buddha768
    @buddha768 3 วันที่ผ่านมา

    Thank you for making such good video on java8. Can you please write java program on java 8? Find the length of the longest substring with all distinct characters

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

    I love ur explanation....thank u very much mam... U r helping people like me to rock the interview also To understand the concepts... Clear explanation... Nice voice... Too good.... first time viewing ur Vedios also subscribed 😊😊

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

      Thanks Krishna 😊

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

    Thanks

  • @nishantdeep3973
    @nishantdeep3973 ปีที่แล้ว +7

    Hey mam... started learning Java 8 6 months ago from ur given playlist as a beginner and now cracking multiple coding rounds in MNCs. Thanx a lot for that, I have one query if u can pls include in next video - the approach that u have used in reverse array via forEach(Consumer Interface) ,how can we done same for checking integerPalindrome via filter( Predicate).

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

      Many many congratulations Nishant for cracking interviews 🎉🎉🎉🎉 well done Man keep learning keep shining 🌟🌟. Sure👍👍

    • @BlueBird-yg4po
      @BlueBird-yg4po 9 หลายเดือนก่อน

      Where can I find interview

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

    Nice questions and its solution. Keep up creating videos !

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

      sure nikunj we will create more like this

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

    It is nice topic are covered on java 8 features 😊

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

    thank you mam, the way of explaining is very superb

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

      You are welcome

  • @vikasrai4915
    @vikasrai4915 23 วันที่ผ่านมา

    Very nice explaination, I finished the whole playlist in 2 days, meanwhile I was wondering whether I can get the notes and code shown in the videos, it would be really helpful, I have some interviews, will need that for revision.
    Thanks

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

    Your explanation is always awesome mam.. keep rock

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

    Awesome, waiting for next vh ideo

    • @CodeDecode
      @CodeDecode  11 หลายเดือนก่อน

      sure we will upload it soon

  • @paridadeepika
    @paridadeepika 11 หลายเดือนก่อน

    Thank u so much for sharing such videos..

    • @CodeDecode
      @CodeDecode  11 หลายเดือนก่อน

      🙂👍

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

    Always a big fan. Thanks.

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

      ❤️❤️

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

    Very useful thanks

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

    Really so useful ...ur videos r awesome..pls make some professional java courses olayilisy

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

    firts time viewing your vedio best helpfull vedio mam ....i subscribed and like .....and heartly thanku mam

    • @CodeDecode
      @CodeDecode  2 หลายเดือนก่อน

      Thanks Ajeet 😊

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

    Absolutely magnificent

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

      Thanks 🙂👍

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

      @@CodeDecode will you plz try some complex problems in data structures

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

    Thanks a lot

    • @CodeDecode
      @CodeDecode  3 หลายเดือนก่อน

      Most welcome

  • @Sigma-Coding-dm3it
    @Sigma-Coding-dm3it 7 หลายเดือนก่อน +1

    great job maam

    • @CodeDecode
      @CodeDecode  7 หลายเดือนก่อน

      Thanks 👍👍

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

    Answer for Last Question:
    int[] numbers = {2, 4, 6, 8};
    int except = 4;
    int res = Arrays.stream(numbers).filter(n -> n != except).reduce(1, (n1, n2) -> n1 * n2);
    System.out.println(res);

  • @supriya0129
    @supriya0129 9 หลายเดือนก่อน +5

    Instead of using available functions explain with logic because HRs only asks for logic

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

    good explanation.

    • @CodeDecode
      @CodeDecode  2 หลายเดือนก่อน

      Thanks 😊👍

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

    Great video

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

      Thanks Akash 🙂🙂

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

    Great🎉

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

      Thanks Sameer 👍🙂

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

    well explained

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

    hi, can u please do a video on HashMap custom key ?

  • @nivaschintu8850
    @nivaschintu8850 7 วันที่ผ่านมา

    It's better if you solve them without inbuilt methods
    As beginning cannot understand the methods directly

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

    Please upload more videos on stream

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

      Sure we will upload it soon

  • @start1learn-n171
    @start1learn-n171 5 หลายเดือนก่อน +1

    Tq

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

      😊👍

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

    We need many more questions

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

      Sure we will cover it soon

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

    Bring more videos for this

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

      Sure we will create it soon

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

    👍☺️

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

    Indori Rocks !!!

  • @user-ur8fy9ef1z
    @user-ur8fy9ef1z ปีที่แล้ว

    Hi,
    Do you have any video how to debug the program in Java streams?
    Example: I do operation on stream then filter and then collect to a list.. if there are 1000 records and seems my 40th record is not filtering properly. How can i debug in eclipse with out using peek and in normal debug mode.. because usually we work with objects like employee and want to check either name or id or some other details of it.
    Can you please create a video for this or if you have any explanation, can you please let know.. looking forward for your response

    • @user-ur8fy9ef1z
      @user-ur8fy9ef1z ปีที่แล้ว

      For example, in the method reverseGivenArrayInPlace, in the foreach intermediate operator, if developer would like to check the values for i=2, then how can he peek there (not exactly peek, stop the running and check values there)?
      Finally, you do making great videos for the developer community. Thank you!!

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

    🙏👍💯

  • @anilrouto4513
    @anilrouto4513 11 หลายเดือนก่อน

    When can we expect the next video ???

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

    Informative Java 8 Interview Series, thanku, mam I think this one is the last video of this Series, not able to find the videos of last 2 questions of this current video..
    1) Remove duplicates preserving order.
    2) Product of all elements except current element.
    Please make video on this if not made because ur logic & explanations really open ups the mind to think in different approach.
    thanku mam

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

    The approach to Q1 is not the best.
    Sorting is expensive than searching so a linear search is much better to use.

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

    liked commets

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

      Thanks Ram 🙂👍

  • @chintu069
    @chintu069 8 หลายเดือนก่อน

  • @mohammedraza4846
    @mohammedraza4846 6 วันที่ผ่านมา

    Nome of the interviewer will ask you to use pre defined Classes and methods, you need to write the logic specially for freshers

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

    When will the next video be posted arrays programming?

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

      Soon Ajit 👍👍

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

    We can solve this problem using Max heap

    • @CodeDecode
      @CodeDecode  11 หลายเดือนก่อน

      👍👍

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

    Hi please provide remaining array questions

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

      Sure 👍

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

    Last question Answere:
    int[] arr = {2, 3, 4, 5};
    int[] ints = Arrays.stream(arr).
    map(i -> Arrays.stream(arr).filter(j -> j != i).reduce(1, (a, b) -> a * b)).toArray();

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

      breaks when there are duplicate elements

    • @akshayjawale1372
      @akshayjawale1372 8 หลายเดือนก่อน

      how to solve this?@@inzi27

  • @akashtanajigurav8226
    @akashtanajigurav8226 3 หลายเดือนก่อน

    1 Question ] Answer
    package z_pracxtice;
    public class xyzz {
    public static void main(String[] args) {

    int arr1[]= {10, 20, 30, 40, 50,50};
    int big =0;
    int sm=0;
    for(int i=0;i

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

    We can using distinct to remove duplicates.

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

      Multiple multiple ways of doing same thing Arpit 👍👍

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

    String[] strings = {"Banana","Apricot","Apple","Strawberry","Mango","Pineapple"};
    int maxLength = Arrays.stream(strings).mapToInt(string -> strings.length).max().orElse(0);
    System.out.println("Length of longest string:" +maxLength);
    Can you check this one, I'm getting wrong output of 6 instead of 10

    • @AshokNarayana-jr2wt
      @AshokNarayana-jr2wt ปีที่แล้ว +1

      yeah same for me also...but using method reference worked for me
      int max=Arrays.stream(items).mapToInt(String ::length).max().orElse(0); try these one

    • @AshokKumar-ml5pn
      @AshokKumar-ml5pn ปีที่แล้ว +2

      int maxLength = Arrays.stream(strings).mapToInt(string -> string.length()).max().orElse(0);

    • @AshokKumar-ml5pn
      @AshokKumar-ml5pn ปีที่แล้ว

      Check int maxLength line once

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

      Can you check string -> strings.length . It should be string.length (not with an s)

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

      That's because the line where method reference is used, there Suresh has written wrong code. He is mapping string with arrays.length and not string.length.
      He is doing strings.length not string.length. Hence wrong answer

  • @eminentAp
    @eminentAp 6 หลายเดือนก่อน

    Questions with timing :-
    Q1 - Given an array of integers, write a java8 program to find the second smallest element - 0:33
    Q2 - Given two arrays of integers, write a java8 program to find the common elements between them - 6:31
    Q3 - Write a java8 program to reverse an array of integers in-place - 14:02
    Q4 - Given an array of strings, write a java8 program to find the length of the longest string - 18:59

  • @Srikanth-mp2li
    @Srikanth-mp2li 3 หลายเดือนก่อน

    Audio not clear

  • @rajnikantyadav1298
    @rajnikantyadav1298 3 หลายเดือนก่อน

    This is not for beginners 😅😅 and we can use more simple ways to solve these problems.

  • @Oscar-zu3lo
    @Oscar-zu3lo ปีที่แล้ว

    Promo'SM ✅

  • @DushmantaKSahu
    @DushmantaKSahu 2 หลายเดือนก่อน

    reverse a list--- List arr=Arrays.asList(1,2,3,4,5);
    arr.stream().collect(Collectors.toCollection(LinkedList::new)).descendingIterator().forEachRemaining(System.out::println);

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

    String[] str = new String[]{"Apple","Banana","Apple","Grapes","Banana"};
    List stringList = Arrays.stream(str)
    .collect(Collectors.groupingBy(s -> s, Collectors.counting()))
    .entrySet().stream()
    .filter(entry -> entry.getValue() < 2)
    .map(Map.Entry::getKey)
    .collect(Collectors.toList());
    System.out.println(stringList);//removing duplicates while preserving original order