Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Java 15 Interview Questions and Answers

Experienced / Expert level questions & answers

Ques 1. What is ZGC: A Scalable Low-Latency Garbage Collector in Java 15?

The Z Garbage Collector, or ZGC, promises not to exceed pause times of 10 ms while reducing overall application throughput by no more than 15% compared to the G1GC (the reduction in throughput is the cost of low latency).

ZGC supports heap sizes from 8 MB up to 16 TB.

The pause times are independent of both the heap size and the number of surviving objects.

Like G1, ZGC is based on regions, is NUMA compatible and can return unused memory to the operating system.

You can configure ZGC with a "soft" heap upper limit (VM option -XX:SoftMaxHeapSize): ZGC will only exceed this limit if necessary to avoid an OutOfMemoryError.

To activate ZGC, use the following VM option:

-XX:+UseZGC

Is it helpful? Add Comment View Comments
 

Ques 2. What is Shenandoah: A Low-Pause-Time Garbage Collector in Java 15?

Just like ZGC, Shenandoah promises minimal pause times, regardless of the heap size.

You can read about exactly how Shenandoah achieves this on the Shenandoah wiki.

You can activate Shenandoah with the following VM option:

-XX:+UseShenandoahGC

Just like G1 and ZGC, Shenandoah returns unused memory to the operating system after a while.

There is currently no support for NUMA and SoftMaxHeapSize; however, at least NUMA support is planned.

Is it helpful? Add Comment View Comments
 

Ques 3. What Is Biased Locking in Java 15?

Biased locking is an optimization of thread synchronization aimed at reducing synchronization overhead when the same monitor is repeatedly acquired by the same thread (i.e., when the same thread repeatedly calls code synchronized on the same object).

In the example above, this means that the first time the add() method is called, the vector monitor is biased to the thread in which the test method is executed. This bias speeds up the monitor's acquisition in the following 9,999,999 add() method calls.

Is it helpful? Add Comment View Comments
 

Ques 4. Why Was Biased Locking Disabled in Java 15?

Biased locking mainly benefits legacy applications that use data structures such as Vector, Hashtable, or StringBuffer, where each access is synchronized.

Modern applications usually use non-synchronized data structures such as ArrayList, HashMap, or StringBuilder – and the data structures optimized for multithreading in the java.util.concurrent package.

Because the code for biased locking is highly complex and deeply intertwined with the JVM code, it requires a great deal of maintenance and makes changes within the JVM's synchronization system costly and error-prone.

Therefore, the JDK developers decided in JDK Enhancement Proposal 374 to disable biased locking by default, mark it as "deprecated" in Java 15 and remove it entirely in one of the following releases.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Related differences

Java 14 vs Java 15Java 15 vs Java 16

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
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
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