21 Modern Java questions from the Java bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.
Free to start: the 2-minute IT readiness check — six questions and a result.
A.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
B.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
C.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
D.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
Answer + AI explanation with Pro
2. Which term means: "a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString"?
Junior
A.var keyword
B.virtual thread
C.record
D.switch expression
Answer + AI explanation with Pro
3. Which statement is correct?
Junior
A.record — a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
B.record — a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
C.record — a class or interface that restricts which other classes may extend or implement it using a permits clause
D.record — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Answer + AI explanation with Pro
4. What is sealed class?
Mid
A.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
B.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
C.a class or interface that restricts which other classes may extend or implement it using a permits clause
D.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
Answer + AI explanation with Pro
5. Which term means: "a class or interface that restricts which other classes may extend or implement it using a permits clause"?
Mid
A.record
B.pattern matching for instanceof
C.sealed class
D.virtual thread
Answer + AI explanation with Pro
6. Which statement is correct?
Mid
A.sealed class — a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
B.sealed class — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
C.sealed class — a class or interface that restricts which other classes may extend or implement it using a permits clause
D.sealed class — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
Answer + AI explanation with Pro
7. What is var keyword?
Junior
A.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
B.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
C.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
D.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
Answer + AI explanation with Pro
8. Which term means: "local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer"?
Junior
A.pattern matching for instanceof
B.var keyword
C.record
D.text block
Answer + AI explanation with Pro
9. Which statement is correct?
Junior
A.var keyword — a class or interface that restricts which other classes may extend or implement it using a permits clause
B.var keyword — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
C.var keyword — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
D.var keyword — a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
Answer + AI explanation with Pro
10. What is switch expression?
Mid
A.a class or interface that restricts which other classes may extend or implement it using a permits clause
B.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
C.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
D.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Answer + AI explanation with Pro
11. Which term means: "a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements"?
Mid
A.virtual thread
B.sealed class
C.switch expression
D.var keyword
Answer + AI explanation with Pro
12. Which statement is correct?
Mid
A.switch expression — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
B.switch expression — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
C.switch expression — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
D.switch expression — a class or interface that restricts which other classes may extend or implement it using a permits clause
Answer + AI explanation with Pro
13. What is virtual thread?
Senior
A.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
B.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
C.a class or interface that restricts which other classes may extend or implement it using a permits clause
D.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
Answer + AI explanation with Pro
14. Which term means: "a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread"?
Senior
A.sealed class
B.text block
C.virtual thread
D.pattern matching for instanceof
Answer + AI explanation with Pro
15. Which statement is correct?
Senior
A.virtual thread — a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
B.virtual thread — a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
C.virtual thread — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
D.virtual thread — a class or interface that restricts which other classes may extend or implement it using a permits clause
Answer + AI explanation with Pro
16. What is text block?
Mid
A.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
B.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
C.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
D.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Answer + AI explanation with Pro
17. Which term means: "a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter"?
Mid
A.virtual thread
B.pattern matching for instanceof
C.switch expression
D.text block
Answer + AI explanation with Pro
18. Which statement is correct?
Mid
A.text block — a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
B.text block — a class or interface that restricts which other classes may extend or implement it using a permits clause
C.text block — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
D.text block — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
Answer + AI explanation with Pro
19. What is pattern matching for instanceof?
Senior
A.a class or interface that restricts which other classes may extend or implement it using a permits clause
B.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
C.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
D.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
Answer + AI explanation with Pro
20. Which term means: "a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast"?
Senior
A.text block
B.pattern matching for instanceof
C.virtual thread
D.sealed class
Answer + AI explanation with Pro
21. Which statement is correct?
Senior
A.pattern matching for instanceof — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
B.pattern matching for instanceof — a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
C.pattern matching for instanceof — a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
D.pattern matching for instanceof — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Answer + AI explanation with Pro
Free to start
Start with a free readiness check
Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Modern Java question come with Pro.