Principais perguntas e respostas de entrevista e testes online
Plataforma educacional para preparacao de entrevistas, testes online, tutoriais e pratica ao vivo

Desenvolva habilidades com trilhas de aprendizado focadas, simulados e conteudo pronto para entrevistas.

WithoutBook reune perguntas de entrevista por assunto, testes praticos online, tutoriais e guias comparativos em um unico espaco de aprendizado responsivo.

Preparar entrevista

Java 8 perguntas e respostas de entrevista

Test your skills through the online practice test: Java 8 Quiz Online Practice Test

Diferencas relacionadas

Java 7 vs Java 8Java 8 vs Java 9

Pergunta 16. Given a list of employees, sort all the employee on the basis of age by using java 8 APIs only.

You can simply use sort method of list to sort the list of employees.
List<Employee> employeeList = createEmployeeList();
        employeeList.sort((e1,e2)->e1.getAge()-e2.getAge());
        employeeList.forEach(System.out::println);

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 17. Given the list of employees, find the employee with name 'John' using Java 8 API.

Check the following code:
List<Employee> employeeList = createEmployeeList();
        Optional<Employee> e1 = employeeList.stream()
                  .filter(e->e.getName().equalsIgnoreCase("Mary")).findAny();
        if(e1.isPresent())
            System.out.println(e1.get());

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 18. Given a list of employee, find maximum age of employee using Java 8 API.

Check the following code:
List<Employee> employeeList = createEmployeeList();
        OptionalInt max = employeeList.stream().
                          mapToInt(Employee::getAge).max();
        if(max.isPresent())
            System.out.println("Maximum age of Employee: "+max.getAsInt());

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 19. Difference between Intermediate and terminal operations in Stream.

Java 8 Stream supports both intermediate and terminal operation.
  • Intermediate operations are lazy in nature and do not get executed immediately. Terminal operations are not lazy, they are executed as soon as encountered.
  • Intermediate operation is memorized and is called when terminal operation is called.
  • All Intermediate operations return stream as it just transforms stream into another and terminal operation don't.

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 20. Provide some examples of Intermediate operations.

Example of Intermediate operations are:
  • filter(Predicate)
  • map(Function)
  • flatmap(Function)
  • sorted(Comparator)
  • distinct()
  • limit(long n)
  • skip(long n)

Isto e util? Adicionar comentario Ver comentarios
 

Mais uteis segundo os usuarios:

Copyright © 2026, WithoutBook.