Java — Lambda expressions, Functional interfaces, Stream API
Today, you can do Java functional programming with some of the agentic coding tools.
However, very often, a Java knowledge test in interviews involves live coding related to Java functional programming.
These questions with solutions can be a quick reminder for your interview test because you don’t do Java functional programming every day.
Enjoy solving these questions. My recommendation:
Put some effort into solving, for example 15 minutes
If you can’t solve the problem in 15 minutes, look at the solution and try to understand it.
After understanding the solution, try to write the solution code yourself without looking at the solution.
Given a list of integers, separate odd and even numbers? Solution 01
How do you remove duplicate elements from a list using Java 8 streams? Solution 02
How do you find frequency of each character in a string using Java 8 streams? Solution 03
How do you find frequency of each element in an array or a list? Solution 04
How do you sort the given list of decimals in reverse order? Solution 05
Given a list of strings, join the strings with ‘[‘ as prefix, ‘]’ as suffix and ‘,’ as delimiter? Solution 06
From the given list of integers, print the numbers which are multiples of 5? Solution 07
Given a list of integers, find maximum and minimum of those numbers? Solution 08
How do you merge two unsorted arrays into single sorted array using Java 8 streams? Solution 09
How do you merge two unsorted arrays into single sorted array without duplicates? Solution 10
How do you get three maximum numbers and three minimum numbers from the given list of integers? Solution 11
Java 8 program to check if two strings are anagrams or not? Solution 12
Find sum of all digits of a number in Java 8? Solution 13
Find second largest number in an integer array? Solution 14
Given a list of strings, sort them according to increasing order of their length? Solution 15
Given an integer array, find sum and average of all elements? Solution 16
How do you find common elements between two arrays? Solution 17
Reverse each word of a string using Java 8 streams? Solution 18
How do you find sum of first 10 natural numbers? Solution 19
Reverse an integer array Solution 20
Print first 10 even numbers Solution 21
How do you find the most repeated element in an array? Solution 22
Palindrome program using Java 8 streams Solution 23
Given a list of strings, find out those strings which start with a number? Solution 24
How do you extract duplicate elements from an array? Solution 25
Print duplicate characters in a string? Solution 26
Find first repeated character in a string? Solution 27
Find first non-repeated character in a string? Solution 28
Fibonacci series Solution 29
First 10 odd numbers Solution 30
How do you get last element of an array? Solution 31
Find the age of a person in years if the birthday has given? Solution 32
GitHub with source code: https://github.com/Milan-Karajovic/JavaFunctionalProgrammingTest
𝐌𝐢𝐥𝐚𝐧 𝐊𝐚𝐫𝐚𝐣𝐨𝐯𝐢ć
𝐏𝐨𝐫𝐭𝐟𝐨𝐥𝐢𝐨: https://milan.karajovic.rs
𝐅𝐨𝐥𝐥𝐨𝐰 𝐦𝐞 on 𝐋𝐢𝐧𝐤𝐞𝐝𝐈𝐧: https://lnkd.in/e3cH854Q
Top comments (0)