Java MCQs

Multiple choice questions on core Java, object-oriented programming, inheritance, JVM, exceptions, and collections.

37 MCQs3 subtopicsProgrammingAll Levels
Key Concept Overview & Exam Context

Review core principles of Java before answering questions. These questions simulate placement technical assessments (TCS, Infosys, Amazon), university exams (CS/IT), and technical certifications.

Target Readiness
Placements & Job Interviews
Question Format
Multiple-Choice with Explanations
Verified Solutions
Step-by-step Output Traces

Java MCQ Questions

Page 1 of 2 (37 total)
Q1

What is the purpose of the 'final' keyword when applied to a variable in Java?

medium
Correct Answer: It prevents the variable from being reassigned after its initial value is set
Explanation:
Once a final variable is assigned a value, attempting to reassign it causes a compile-time error. This is commonly used for constants, though for object references it only prevents reassigning the reference, not changing the object's internal state.
Q2

What is method overloading in Java?

easy
Q3

How does method overriding differ from method overloading?

medium
Q4

What does the 'static' keyword mean when applied to a method in Java?

easy
Q5

What is the purpose of a constructor in Java?

easy
Q6

What is the difference between '==' and the equals() method when comparing Java objects?

medium
Q7

What is the purpose of the 'this' keyword in Java?

easy
Q8

What happens when an array index is accessed that is outside the bounds of the array in Java?

easy
Q9

What is autoboxing in Java?

medium
Q10

What is the key difference between an abstract class and an interface in Java, in terms of state?

medium
Q11

What is the purpose of the 'super' keyword in Java?

easy
Q12

What is a NullPointerException typically caused by?

easy
Q13

What is the purpose of garbage collection in Java?

medium
Q14

Which access modifier makes a member accessible only within its own class?

easy
Q15

What is the difference between StringBuilder and String in Java?

medium
Q16

What does the 'instanceof' operator check in Java?

medium
Q17

What is the purpose of a try-with-resources statement in Java?

medium
Q18

What does the term 'immutable' mean when describing the String class in Java?

easy
Q19

What is the default access modifier in Java when no modifier is explicitly specified?

medium
Q20

What is the purpose of an interface in Java?

easy
Showing 1 to 20 of 37 questions