Member-only story
30 Essential Java and Spring Interview Questions with One-Line Answers
If you’re preparing for a Java and Spring interview, it’s crucial to master theory-based questions to demonstrate your understanding of core concepts. Here are 30 common questions with concise one-line answers to help you get started.
Java Interview Questions
- What is the Java Virtual Machine (JVM)?
Answer: A runtime environment that executes Java bytecode. - What is the difference between JDK, JRE, and JVM?
Answer: JDK is for development, JRE is for running applications, and JVM is the engine that executes bytecode. - What are Java’s access modifiers?
Answer:public
,protected
,default
(no modifier), andprivate
. - What is the difference between
final
,finally
, andfinalize
?
Answer:final
prevents modification,finally
is for cleanup intry-catch
, andfinalize
is used for garbage collection. - What is the purpose of the
transient
keyword?
Answer: Marks a variable to be excluded during serialization. - What is a marker interface?
Answer: An interface with no methods or fields, used to signal metadata (e.g.,Serializable
). - What is the difference between
==
andequals()
?
Answer:==
checks reference equality, whileequals()
checks value equality.