Modern Java interview questions

21 real Modern Java questions from the Java bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is record?

Junior
  1. A.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
  2. B.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  3. C.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  4. D.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
Reveal the answer + AI explanation — free account

2. Which term means: "a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString"?

Junior
  1. A.var keyword
  2. B.virtual thread
  3. C.record
  4. D.switch expression
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Junior
  1. A.record — a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
  2. B.record — a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
  3. C.record — a class or interface that restricts which other classes may extend or implement it using a permits clause
  4. D.record — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Reveal the answer + AI explanation — free account

4. What is sealed class?

Mid
  1. A.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
  2. B.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  3. C.a class or interface that restricts which other classes may extend or implement it using a permits clause
  4. D.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. 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
  2. B.sealed class — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  3. C.sealed class — a class or interface that restricts which other classes may extend or implement it using a permits clause
  4. D.sealed class — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
Reveal the answer + AI explanation — free account

7. What is var keyword?

Junior
  1. A.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
  2. B.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  3. C.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  4. D.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
Reveal the answer + AI explanation — free account

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
  1. A.pattern matching for instanceof
  2. B.var keyword
  3. C.record
  4. D.text block
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Junior
  1. A.var keyword — a class or interface that restricts which other classes may extend or implement it using a permits clause
  2. B.var keyword — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  3. C.var keyword — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
  4. 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
Reveal the answer + AI explanation — free account

10. What is switch expression?

Mid
  1. A.a class or interface that restricts which other classes may extend or implement it using a permits clause
  2. B.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
  3. C.a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
  4. D.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Mid
  1. A.switch expression — local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  2. B.switch expression — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  3. C.switch expression — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
  4. D.switch expression — a class or interface that restricts which other classes may extend or implement it using a permits clause
Reveal the answer + AI explanation — free account

13. What is virtual thread?

Senior
  1. A.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  2. B.local variable type inference introduced in Java 10 that lets the compiler deduce a variable's type from its initializer
  3. C.a class or interface that restricts which other classes may extend or implement it using a permits clause
  4. D.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
Reveal the answer + AI explanation — free account

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
  1. A.sealed class
  2. B.text block
  3. C.virtual thread
  4. D.pattern matching for instanceof
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Senior
  1. A.virtual thread — a concise immutable data carrier introduced in Java 16 that auto-generates a constructor, accessors, equals, hashCode, and toString
  2. 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
  3. C.virtual thread — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  4. D.virtual thread — a class or interface that restricts which other classes may extend or implement it using a permits clause
Reveal the answer + AI explanation — free account

16. What is text block?

Mid
  1. A.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
  2. B.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
  3. C.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
  4. D.a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
Reveal the answer + AI explanation — free account

17. Which term means: "a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter"?

Mid
  1. A.virtual thread
  2. B.pattern matching for instanceof
  3. C.switch expression
  4. D.text block
Reveal the answer + AI explanation — free account

18. Which statement is correct?

Mid
  1. 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
  2. B.text block — a class or interface that restricts which other classes may extend or implement it using a permits clause
  3. C.text block — a form of switch introduced in Java 14 that yields a value using arrow labels and requires no break statements
  4. D.text block — a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
Reveal the answer + AI explanation — free account

19. What is pattern matching for instanceof?

Senior
  1. A.a class or interface that restricts which other classes may extend or implement it using a permits clause
  2. B.a feature that binds a tested object to a typed variable in the same expression, removing the need for an explicit cast
  3. C.a lightweight JVM-managed thread finalized in Java 21 that enables massive concurrency without mapping one-to-one to an OS thread
  4. D.a multi-line string literal delimited by triple quotes, introduced in Java 15, that preserves formatting without escape clutter
Reveal the answer + AI explanation — free account

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
  1. A.text block
  2. B.pattern matching for instanceof
  3. C.virtual thread
  4. D.sealed class
Reveal the answer + AI explanation — free account

21. Which statement is correct?

Senior
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Modern Java free