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
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);
}
}
Correct Raushan 👍👍 that edge case scenario is left to be covered like we did in first question 👏👏
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!!
Thanks for creating such videos, would you please create a video continuation of this? This will be very helpful.
Yes we need more such questions covered
Sure 😊👍
@@CodeDecodeYes we need more problems like this...!!
Thanks mam for provides us such a important content..We will waiting for next part of that video 🤗🎉
👍😊
Love to watch ur content. It will be more helpful if u provide ur source code for same
Love you for this video 👌👌👌 what a video 👌👌 waiting for next part
Sure 😊😊
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
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 😊😊
Thanks Krishna 😊
Thanks
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).
Many many congratulations Nishant for cracking interviews 🎉🎉🎉🎉 well done Man keep learning keep shining 🌟🌟. Sure👍👍
Where can I find interview
Nice questions and its solution. Keep up creating videos !
sure nikunj we will create more like this
It is nice topic are covered on java 8 features 😊
Thanks Rushi 🙂
thank you mam, the way of explaining is very superb
You are welcome
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
Your explanation is always awesome mam.. keep rock
Thanks 🙂👍
Awesome, waiting for next vh ideo
sure we will upload it soon
Thank u so much for sharing such videos..
🙂👍
Always a big fan. Thanks.
❤️❤️
Very useful thanks
Thanks
Really so useful ...ur videos r awesome..pls make some professional java courses olayilisy
Soon 🙂🙂
firts time viewing your vedio best helpfull vedio mam ....i subscribed and like .....and heartly thanku mam
Thanks Ajeet 😊
Absolutely magnificent
Thanks 🙂👍
@@CodeDecode will you plz try some complex problems in data structures
Thanks a lot
Most welcome
great job maam
Thanks 👍👍
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);
Instead of using available functions explain with logic because HRs only asks for logic
good explanation.
Thanks 😊👍
Great video
Thanks Akash 🙂🙂
Great🎉
Thanks Sameer 👍🙂
well explained
Thanks
hi, can u please do a video on HashMap custom key ?
It's better if you solve them without inbuilt methods
As beginning cannot understand the methods directly
Please upload more videos on stream
Sure we will upload it soon
Tq
😊👍
We need many more questions
Sure we will cover it soon
Bring more videos for this
Sure we will create it soon
👍☺️
🙂
Indori Rocks !!!
👍👍
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
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!!
🙏👍💯
😊😊
@@CodeDecode 👍
When can we expect the next video ???
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
The approach to Q1 is not the best.
Sorting is expensive than searching so a linear search is much better to use.
liked commets
Thanks Ram 🙂👍
Nome of the interviewer will ask you to use pre defined Classes and methods, you need to write the logic specially for freshers
When will the next video be posted arrays programming?
Soon Ajit 👍👍
We can solve this problem using Max heap
👍👍
Hi please provide remaining array questions
Sure 👍
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();
breaks when there are duplicate elements
how to solve this?@@inzi27
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
We can using distinct to remove duplicates.
Multiple multiple ways of doing same thing Arpit 👍👍
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
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
int maxLength = Arrays.stream(strings).mapToInt(string -> string.length()).max().orElse(0);
Check int maxLength line once
Can you check string -> strings.length . It should be string.length (not with an s)
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
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
Audio not clear
This is not for beginners 😅😅 and we can use more simple ways to solve these problems.
Promo'SM ✅
reverse a list--- List arr=Arrays.asList(1,2,3,4,5);
arr.stream().collect(Collectors.toCollection(LinkedList::new)).descendingIterator().forEachRemaining(System.out::println);
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