Modern Java interview questions

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.

Take the free IT readiness check

or take a mock interview set up for this area

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

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
  1. A.var keyword
  2. B.virtual thread
  3. C.record
  4. D.switch expression

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.record
  2. B.pattern matching for instanceof
  3. C.sealed class
  4. D.virtual thread

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.pattern matching for instanceof
  2. B.var keyword
  3. C.record
  4. D.text block

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.virtual thread
  2. B.sealed class
  3. C.switch expression
  4. D.var keyword

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.sealed class
  2. B.text block
  3. C.virtual thread
  4. D.pattern matching for instanceof

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.virtual thread
  2. B.pattern matching for instanceof
  3. C.switch expression
  4. D.text block

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.text block
  2. B.pattern matching for instanceof
  3. C.virtual thread
  4. D.sealed class

Answer + AI explanation with Pro

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

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.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers