Java 9 Interview Questions

JAVA 9 INTERVIEW QUESTIONS

When Java 9 initial version is released ?

Sep 2017

Mention few new features of Java 9 ?

Java 9 has included many new features.We are point only few

  • Module :Its like component that will contain code and data.
  • JShell :It is command line tool for evaluating declarations, statements, and expressions of the Java programming language
  • private method : Java 9 has introduced private methods in interface.
  • Diamond Operator : Java 9 has diamond operator with anonymous inner classes.
  • Try with Resources : Java 9 has improved Java 7 exception handling try-with-resources.
  • Stream method : Java 9 has introduced stream() method in Optional class.
  • Reactive Stream : Introduced Reactive Stream which is used for Asynchronous communication
  • Process API Update : Updated process API for controlling and managing operating system processes.
  • Factory Method for Collections: Introduced new factory method on the List, Set, and Map interfaces to create immutable collection for small number of elements.
  • Lightweight JSON : API introduced to consume and produce documents via JSON.
  • Improved JavaDocs : Supports HTML5 output generation.

How can we create Module in java 9 ?

Simple steps to create Module with Example In Java 9

What is REPL ?

REPL stands for Read-Eval-Print Loop.Oracle has introduced jshell which is command line tool for evaluating declarations, statements, and expressions of the Java programming language.JShell API enables application to use REPL (Read-Eval-Print Loop) functionality.

How can we view JShell commands ?

/help

Give Example of immutable Collections creation in java 9 ?

Simple steps to create Immutable Collection In Java 9

Can we have private method or private static method in Interface ?

Yes , in Java 9 it's possible.

Give one example of private method in Interface in Java 9 ?

Simple steps to create private method in interface In Java 9.

What are Stream API improvement in Java 9?

  • dropWhile : It will drop all values from start until predicate returns false.In other word it will remove prefix matching that predicate.
  • takeWhile : It will take all values from start from stream until predicate returns false.
  • iterate : It has hasNext predicate which will stop loop if predicate is false
  • ofNullable : It is introduced to prevent NullPointerExceptions.

Give Stream API improvement Example in Java 9 ?

Stream API Improvement Example In Java 9.

Give try with resources improvement Example in Java 9 ?

try with resources Improvement Example In Java 9.

What are two attributes added in @Deprecated annotation in java 9 ?

  • forRemoval
  • since

What is the syntax for @Deprecated in java 9 ?


@Deprecated (forRemoval=true , since="9")

What is the significance of forRemoval in @Deprecated ?

It is boolean value which indicates that this method is not going to be in future release if value is true.

What is the default value of forRemoval in @Deprecated ?

false

What is the significance of since in @Deprecated ?

It is String value which informs from which release this method is Deprecated.

Can we use diamond operator for inner classes in java 9 ?

Yes.

Give one example of diamond operator for inner class in Java 9 ?

Simple steps of diamond operator for inner class In Java 9.

What are the new methods added in Optional class in java 9?

  • ifPresentOrElse
  • or
  • stream

What is the syntax of ifPresentOrElse() ?


public void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction)

Give one example of ifPresentOrElse() ?

package com.preparationforinterview.optional;

import java.util.Optional;

public class OptionalInJava9 {

	public static void main(String args[]) {

		Optional<String> optional = Optional.empty();
		optional.ifPresentOrElse(var -> System.out.println(var), () -> System.out.println("Data is missing"));

	}

}



Visit Others Links

Interview Questions Top Elasticsearch Interview Question
Top Kubernetes Interview Question
Top HTTP Interview Question
Top PouchDB Interview Question
Top Pivotal Cloud Foundry (pcf) Interview Question
Top Apache Camel Interview Question
Top Docker Interview Question
Top Gradle Interview Question
Top Generics Interview Questions In Java
Java 9 Interview Questions
Top Maven Interview Question
Top RabbitMQ Interview Question
Top Spring Batch Interview Question
Top Spring Boot Interview Question
Top Tika Interview Question
Top Kotlin Interview Question
Top OpenShift Interview Question
Top Polymer Interview Question
Top WebGL Interview Question
Top Continuous Integration Interview Question
Top Spring Cloud Interview Question
Top JOGL Interview Question
Top JFreeChart Interview Question
Java MultiThreading Interview Question
Top Spring ROO Interview Question
Top Seaborn Interview Question
Top TestRail Interview Question
Top LolCode Interview Question
Top Spring Transaction Management Interview Question
Top DynamoDB Interview Question
Top PySpark Interview Question
Top SaltStack Interview Question
Top Spring AOP Interview Question
© 2019 PreparationForInterview.com