Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address
Check our LIVE MOCK INTERVIEWS

Java 11 Interview Questions and Answers

Experienced / Expert level questions & answers

Ques 1. What is Java Mission Control in Java 11?

Java Mission Control is an application that can analyze the dumps that come from Java Flight Recorder, and give you a graphical overview of what's happening inside of a JVM.

Is it helpful? Add Comment View Comments
 

Ques 2. What is Nest-Based Access Control in Java 11?

Java allows classes and interfaces to be nested within each other. These nested forms have unlimited access to each other, including private fields, methods, and constructors.

Nests allow nested classes, which are part of the same enclosing class but are compiled into different class files, to access each other\'s private members without the need for compilers to insert synthetic accessibility-broadening bridge methods. This is a Java class bytecode level change.

public class TestOuter {    

public void testingOuterPublic() {
}
private void testingOuterPrivate() {
}

class TestInner {
public void testingInner() {
testingOuterPrivate();
}
}
}

TestOuter and TestInner form a nest together, they are each other\'s nestmates.
The method testingOuterPrivate() can be accessed inside inner class, even tough testingOuterPrivate() method is private.

If we compile above class, will get compilation error. This is because of the reason that the outer and nested classes are compiled to different files and they need package-private visibility to access each other\'s private members. JVM access rules do not permit private access between nestmates.

Java 11 provides JVM level support for private access through the \"NestMembers\" and \"NestHost\" attributes within outer / nested classes.

  • NestMembers
    corresponds to nested classes.
  • NestHost
    corresponds to the enclosing outer class.
  • Now these attributes connect outer and nested classes, rather than package-private bridge methods created synthetically.

Using Reflection:

package com.withoutbook;
import java.lang.reflect.Field;

public class TestOuter {
private static int testingNumber = 17;
public static class NestedInnerTest {
public static void test() throws Exception {
Field value = TestOuter.class.getDeclaredField(\"testingNumber\");
value.setInt(null, 12);
}
}
public static void main(String[] args) throws Exception {
NestedInnerTest.test();
System.out.println(TestOuter.testingNumber);
}
}

If we run above code in Java 10, will get below exception:

Exception in thread \"main\" java.lang.IllegalAccessException: 
class com.techgeeknext.TestOuter$NestedInnerTest cannot access a member of class com.techgeeknext.controller.TestOuter with modifiers \"private static\"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:639) at java.base/java.lang.reflect.Field.checkAccess(Field.java:1075)
at java.base/java.lang.reflect.Field.setInt(Field.java:958) at com.techgeeknext.controller.TestOuter$NestedInnerTest.test(TestOuter.java:12)
at com.techgeeknext.controller.TestOuter.main(TestOuter.java:18)

Whereas in Java 11, it will run successfully without exception with below output:

12

Is it helpful? Add Comment View Comments
 

Ques 3. What is Epsilon: A No-Op Garbage Collector in Java 11?

Epsilon is the "No Op" garbage collector. It allocates new memory but never recycles it. Once the application exhausts the available Java heap, the JVM shuts down. It means, Epsilon will allow your application to run out of memory and crash. Elipson is good only for test environments and no-op garbage collector is useful for measuring and managing application performance.

Java 11 also added Z Garbage Collector(ZGC), which promises to manage large heaps with high throughput and short pause times. You need to specify below two runtime switches on the command line, to tell the JVM to use the Epsilon GC

XX:+UnlockExperimentalVMOptions
-XX:+UseEpsilonGC

Below command generate heap dump if JVM runs out of memory.

-XX:HeapDumpOnOutOfMemoryError

Run specified command when an out-of-memory error occurs.

-XX:OnOutOfMemoryError=

Is it helpful? Add Comment View Comments
 

Ques 4. What is Remove the Java EE and CORBA Modules in Java 11?

Java 11 removed the Java EE and CORBA modules from the Java SE Platform and the JDK, these modules were already deprecated in Java 9 with the declared intent to remove them in a future release.

  1. java.xml.ws (JAX-WS, plus the related technologies SAAJ and Web Services Metadata)
  2. java.xml.bind (JAXB)
  3. java.activation (JAF)
  4. java.xml.ws.annotation (Common Annotations)
  5. java.corba (CORBA)
  6. java.transaction (JTA)
  7. java.se.ee
  8. jdk.xml.ws (Tools for JAX-WS)
  9. jdk.xml.bind (Tools for JAXB)

Is it helpful? Add Comment View Comments
 

Ques 5. What is HTTP Client (Standard) in Java 11?

It standardizes Http Client API, in the java.net.http package, based upon the incubated API, and removed the incubated API. The new API supports both HTTP/1.1 and HTTP/2. It is designed to enhance the overall performance of sending requests by a client and receiving responses from the server. It also natively supports WebSockets.

Is it helpful? Add Comment View Comments
 

Ques 6. What is Key Agreement with Curve25519 and Curve448 in Java 11?

Java makes further improvements in cryptography which provides security and performance. This feature implements a key agreement using Curve25519 and Curve448. Other cryptography libraries, such as OpenSSL and BoringSSL, already support key exchanges using Curve25519 and Curve448.

Is it helpful? Add Comment View Comments
 

Ques 7. What is Flight Recorder in Java 11?

Java Flight Recorder (JFR) is a profiling tool that collects data about events during the execution of a Java application in Java Virtual Machine (JVM). JFR is integrated into the JVM and part of the JDK distribution.

  • Using Command Line: Compile FlightRecTest Java program by executing the below command, which will generate FlightRecTest.class file at src/com/withoutbook/flightrecorder location.
    javac -d out -sourcepath src/com/withoutbook/flightrecorder/FlightRecTest.java
    Once compilation is successful, the following options can be taken to start the program:
    java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder  -XX:StartFlightRecording=duration=200s,filename=recording.jfr  -cp ./out/ com.withoutbook.flightrecorder.FlightRecTest
  • Using Diagnostic Command: The jcmd tool also allows registration of events to start. To start a 70-second recording on the running Java process with the identifier 4532 and save it to recording.jfr in the current directory, use the following:
    jcmd 4532 JFR.start duration=70s filename=recording.jfr
    Below commands relevant to Java Flight Recorder are:
    //Start a recording.JFR.start//It check the status of all recordings running for the specified process, including the recording file name, identification number, duration.JFR.check//It stop recording with a specific identification number, by default, recording 1 is stopped.JFR.stop//It dump the data collected by the recording with a specific identification number, by default, data from recording 1 is dumped.JFR.dump

Is it helpful? Add Comment View Comments
 

Ques 8. What are ChaCha20 and Poly1305 Cryptographic Algorithms in Java 11?

Java 11 has Implement the ChaCha20 and ChaCha20-Poly1305 ciphers.

ChaCha20 is a new stream cipher which replaces the older, insecure RC4 stream cipher.
Poly1305 is a cryptographic Message Authentication Code (MAC), used on both Encrypted and Decrypted messages, it creates the authentication token and guarantees the integrity of the message.

In ChaCha20-Poly1305 algorithm, ChaCha20 Stream cipher performs the Encryption and Poly1305 performs the Authentication. The ChaCha20 and ChaCha20-Poly1305 algorithms will implement the javax.crypto.CipherSpi API within the SunJCE provider.

Is it helpful? Add Comment View Comments
 

Ques 9. What is Low-Overhead Heap Profiling in Java 11?

It provides a way to get information from the JVM about Java object heap allocations that:

  1. Is low-overhead enough to be enabled by default continuously
  2. Is accessible via a well-defined, programmatic interface
  3. Sample all allocations (which is not limited to allocations that are in one particular heap region or that were allocated in one particular way)
  4. It can be defined in an implementation-independent way (i.e., without relying on any particular GC algorithm or VM implementation)
  5. It provide information about both live and dead Java objects.

Is it helpful? Add Comment View Comments
 

Ques 10. What is Transport Layer Security (TLS) 1.3 in Java 11?

Transport Layer Security, or TLS, is a cryptographic protocol that protects data exchanged over a computer network. TLS (Transport Layer Security) and is the successor to SSL (Secure Sockets Layer). TLS provides secure communication between web browsers and servers.

TLS 1.3 is a major revision of the TLS protocol and provides significant security and performance improvements over previous versions.

Is it helpful? Add Comment View Comments
 

Ques 11. Write about Deprecate the Nashorn JavaScript Engine in Java 11?

Below two JDK modules will be terminally deprecated, by using annotation @Deprecated(forRemoval=true):

  1. jdk.scripting.nashorn -- contains the jdk.nashorn.api.scripting and jdk.nashorn.api.tree packages.
  2. jdk.scripting.nashorn.shell -- contains the jjs tool. Running jjs will display a warning:

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Related differences

Java 10 vs Java 11Java 11 vs Java 12

Related interview subjects

JUnit interview questions and answers - Total 24 questions
Spring Framework interview questions and answers - Total 53 questions
Java Design Patterns interview questions and answers - Total 15 questions
Java 17 interview questions and answers - Total 20 questions
Core Java interview questions and answers - Total 306 questions
Tomcat interview questions and answers - Total 16 questions
Apache Wicket interview questions and answers - Total 26 questions
Java Applet interview questions and answers - Total 29 questions
JAXB interview questions and answers - Total 18 questions
JMS interview questions and answers - Total 64 questions
Log4j interview questions and answers - Total 35 questions
Struts interview questions and answers - Total 84 questions
RMI interview questions and answers - Total 31 questions
Apache Camel interview questions and answers - Total 20 questions
JDBC interview questions and answers - Total 27 questions
Java 11 interview questions and answers - Total 24 questions
JPA interview questions and answers - Total 41 questions
EJB interview questions and answers - Total 80 questions
GWT interview questions and answers - Total 27 questions
Kotlin interview questions and answers - Total 30 questions
Glassfish interview questions and answers - Total 8 questions
Google Gson interview questions and answers - Total 8 questions
Java 21 interview questions and answers - Total 21 questions
JSP interview questions and answers - Total 49 questions
J2EE interview questions and answers - Total 25 questions
Apache Tapestry interview questions and answers - Total 9 questions
Java Swing interview questions and answers - Total 27 questions
Java Mail interview questions and answers - Total 27 questions
Hibernate interview questions and answers - Total 52 questions
JSF interview questions and answers - Total 24 questions
Java 8 interview questions and answers - Total 30 questions
Java 15 interview questions and answers - Total 16 questions
JBoss interview questions and answers - Total 14 questions
Web Services interview questions and answers - Total 10 questions
RichFaces interview questions and answers - Total 26 questions
Servlets interview questions and answers - Total 34 questions
Java Beans interview questions and answers - Total 57 questions
Spring Boot interview questions and answers - Total 50 questions
©2023 WithoutBook