DEV Community

Milan Karajovic
Milan Karajovic

Posted on

Master Java Functional Programming Test — With Solutions

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.

  1. Given a list of integers, separate odd and even numbers? Solution 01

  2. How do you remove duplicate elements from a list using Java 8 streams? Solution 02

  3. How do you find frequency of each character in a string using Java 8 streams? Solution 03

  4. How do you find frequency of each element in an array or a list? Solution 04

  5. How do you sort the given list of decimals in reverse order? Solution 05

  6. Given a list of strings, join the strings with ‘[‘ as prefix, ‘]’ as suffix and ‘,’ as delimiter? Solution 06

  7. From the given list of integers, print the numbers which are multiples of 5? Solution 07

  8. Given a list of integers, find maximum and minimum of those numbers? Solution 08

  9. How do you merge two unsorted arrays into single sorted array using Java 8 streams? Solution 09

  10. How do you merge two unsorted arrays into single sorted array without duplicates? Solution 10

  11. How do you get three maximum numbers and three minimum numbers from the given list of integers? Solution 11

  12. Java 8 program to check if two strings are anagrams or not? Solution 12

  13. Find sum of all digits of a number in Java 8? Solution 13

  14. Find second largest number in an integer array? Solution 14

  15. Given a list of strings, sort them according to increasing order of their length? Solution 15

  16. Given an integer array, find sum and average of all elements? Solution 16

  17. How do you find common elements between two arrays? Solution 17

  18. Reverse each word of a string using Java 8 streams? Solution 18

  19. How do you find sum of first 10 natural numbers? Solution 19

  20. Reverse an integer array Solution 20

  21. Print first 10 even numbers Solution 21

  22. How do you find the most repeated element in an array? Solution 22

  23. Palindrome program using Java 8 streams Solution 23

  24. Given a list of strings, find out those strings which start with a number? Solution 24

  25. How do you extract duplicate elements from an array? Solution 25

  26. Print duplicate characters in a string? Solution 26

  27. Find first repeated character in a string? Solution 27

  28. Find first non-repeated character in a string? Solution 28

  29. Fibonacci series Solution 29

  30. First 10 odd numbers Solution 30

  31. How do you get last element of an array? Solution 31

  32. 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)