Posts

Showing posts from 2026

Java Stream Coding Interview Questions and Solutions

Image
Java Stream API introduced in Java 8 and use functional way (lambda function f(x) -> y) to process a collection. It operates over a source data and returns a transformed immutable object. It is one of the most frequently asked interview topic. If you're preparing for Java developer roles, make sure to go through the below consolidated and compiled coding question and answers to bookmark and practice.   Q. Convert a collection of string to upper case : List<String> list = Arrays . asList ( "Bob" , "Piter" , "Andi" , "Joy" ); List<String> listUpper = list .stream() .map( String::toUpperCase ) .collect(Collectors. toList ()); System. out .println( "listUpper - " +listUpper); Output: listUpper - [BOB, PITER, ANDI, JOY] Q. Find Max value from a collection of integer : List<Integer> listInt = Arrays . asList ( 4 , 5 , 7 , 3 , 23 , 89 ); Optional<Integer> value = listInt ...