50 Frequently asked Java 8 Interview Questions and Answers

1. What are the functional interfaces in Java 8?

Functional interfaces are not a new concept in Java; they are just normal interfaces with fewer modifications. 

  • It can have one abstract method
  • It can have default/static methods.
  • To Implement Lambda Expressions, Method reference, and constructor references
  • It has an annotation named @FunctionalInterface

3. What is the Usage of @SpringBootApplication in SpringBoot Application?

Spring application class used to Boostrap and launch the application from a Java Main Methods, If we define the annotation @SpringBootApplication, the compiler marks the main class as Spring Boot Configuration Class and do all auto configurations and other related services required for SpringBoot.

4. What are all the three configurations @SpringBootApplication Contains?

 @Configuration – Used to enable Java-based configuration

      @ComponentScan – Used to enable component scanning.

      @EnableAutoConfiguration – Used to enable the Auto-configuration feature of Spring Boot.

5. Difference Between @Configuration vs @ComponentScan vs @EnableAutoConfiguration in SpringBoot Application?

@Configuration vs @ComponentScan vs @EnableAutoConfiguration are the basic annotations in the SpringBoot Application. These 3 annotations are used to specify the do the necessary setting in Spring application startup. These are all used in Spring application Main Class.

6. What are the main enhancements in Java 8?

  •  Lambda expressions
  •  Stream API
  •  Collectors class
  •  Method references
  •  IO Enhancements
  • ForEach() method
  • Functional interfaces

7. Java Steam Use?

  • You can use a stream to filter, collect, print, and convert from one data structure to another, etc.
  • Steam is lazy. It evaluates the content when it is required.
  • Steam does not store any elements, it is used to manipulate and helps the developer to do the operational behaviors.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *