Top Java 8 Interview Questions and Answers - PLM Developer

Here are the few top Java 8 Frequently asked Interview Questions and Answers.  There are a few crucial features introduced and improved existing in Java 8. So, you can expect a fair number of Interview Questions from this version in any Java interview. Please go through questions and answers. Add a comment or mail us if anything is missing or you feel like included in this post.

 

Top Java 8 Interview Questions And Answers


Q. What are the new features introduced in Java 8?

  1. Lambda Expression
  2. Stream API
  3. DateTime API
  4. Optional
  5. Default Method
  6. JavaScript Engine

 

Q. What is Lambda Expression?

A. Lambda Expression is an anonymous function that accepts a set of parameters, a Lambda Operator (->), and a function body.


Q. What is Stream API?

A. New Stream API provides the facility of pipeline processing.


Q. What is DatTime API in java 8?

A. In java 8 interoduced new classes LocalDate, LocalTime & LocalDateTime


Q. What is Optional in Java 8?

A. Optional is a final class present in java.util.package. This class uses to represent optional values that are either exist or no exist. It contains either one or zero values. The main advantage of an optional class is to avoid "null" checks and "NullPointerException".


Q. What is the default method in Java 8?

A. In java 8, Interface allows you to add a method implementation with a default access modifier.


Q. What is a JavaScript engine in Java 8?

A. Introduced java based engine to execute JavaScript code.


Q. What are the static default methods?

A. Interface can have a static helper method in java 8 allows having static helper methods.


public interface Birds {

static void Fly() {

System.out.println("Flying....:)");

}

}


Q. What is Functional Interface?

A. A Functional Interface is an interface, which contains only an abstract method. A Functional Interface is also called the SAM interface.

SAM stands for Single Abstract Method. In the Java 8 version, Oracle introduced many functional interfaces. 


Q. How to define our Functional Interface?

  • A. In Java 8, we can define our Functional Interface using @FunctionalInterface annotation. We need to follow the below steps to create a functional interface.
  • Create an interface and add only one abstract method.
  • We cannot add more than one abstract method.
  • Add @FunctionalInterfaceannotation to the definition of the Interface.
  • We can add other methods like default methods and static methods.

See Also:

👉Java Interview Questions & Answers 1

👉Java Interview Questions & Answers 2

👉Java Interview Questions & Answers 3

Post a Comment

0 Comments