Java Programming – Interview Questions

Practice interview questions by difficulty level

Showing: All Questions
Q1. What is Java?
Beginner Level
Java is a high-level, object-oriented, platform-independent programming language.
Q2. Who developed Java?
Beginner Level
Java was developed by James Gosling at Sun Microsystems.
Q3. What is JVM?
Beginner Level
JVM executes Java bytecode and provides platform independence.
Q4. What is JDK?
Beginner Level
JDK is a software development kit used to develop Java applications.
Q5. What is JRE?
Beginner Level
JRE provides libraries and JVM to run Java programs.
Q6. What is bytecode?
Beginner Level
Bytecode is an intermediate code generated by Java compiler.
Q7. Why Java is platform independent?
Beginner Level
Because Java programs run on JVM, not directly on OS.
Q8. What is class in Java?
Beginner Level
A class is a blueprint for creating objects.
Q9. What is object?
Beginner Level
An object is an instance of a class.
Q10. What is main method?
Beginner Level
main() is the entry point of Java program execution.
Q11. What is variable?
Beginner Level
A variable stores data values.
Q12. What are data types?
Beginner Level
They define the type of data a variable can hold.
Q13. What are primitive data types?
Beginner Level
int, float, double, char, boolean etc.
Q14. What is operator?
Beginner Level
Operator performs operations on operands.
Q15. What is conditional statement?
Beginner Level
It executes code based on conditions.
Q16. What are loops?
Beginner Level
Loops repeat execution of code.
Q17. What are loop types in Java?
Beginner Level
for, while, do-while.
Q18. What is array?
Beginner Level
Array stores multiple values of same type.
Q19. What is String class?
Beginner Level
String represents a sequence of characters.
Q20. What is immutable object?
Beginner Level
An object whose value cannot be changed.
Q21. What is constructor?
Beginner Level
Constructor initializes objects.
Q22. What is this keyword?
Beginner Level
this refers to current object.
Q23. What is static keyword?
Beginner Level
static belongs to class rather than object.
Q24. What is method?
Beginner Level
Method is a block of code performing a task.
Q25. What is inheritance?
Beginner Level
Inheritance allows one class to acquire another’s properties.
Q26. What is polymorphism?
Beginner Level
Ability to take multiple forms.
Q27. What is encapsulation?
Beginner Level
Binding data and methods together.
Q28. What is abstraction?
Beginner Level
Hiding implementation details.
Q29. What is interface?
Beginner Level
Interface contains abstract methods.
Q30. What is package?
Beginner Level
Package groups related classes.
Q31. What is access modifier?
Beginner Level
Defines accessibility of classes and members.
Q32. What is public keyword?
Beginner Level
Accessible from anywhere.
Q33. What is private keyword?
Beginner Level
Accessible within the same class only.
Q34. What is protected keyword?
Beginner Level
Accessible within package and subclasses.
Q35. What is final keyword?
Beginner Level
final prevents modification.
Q36. What is exception?
Beginner Level
An error occurring during runtime.
Q37. What is try-catch?
Beginner Level
Used to handle exceptions.
Q38. What is println()?
Beginner Level
Prints output with newline.
Q39. Difference between JDK, JRE and JVM?
Intermediate Level
JDK develops, JRE runs, JVM executes bytecode.
Q40. What is method overloading?
Intermediate Level
Same method name with different parameters.
Q41. What is method overriding?
Intermediate Level
Subclass provides specific implementation.
Q42. What is super keyword?
Intermediate Level
Refers to parent class object.
Q43. Difference between abstract class and interface?
Intermediate Level
Abstract can have methods; interface only declarations.
Q44. What is runtime polymorphism?
Intermediate Level
Method call resolved at runtime.
Q45. What is compile-time polymorphism?
Intermediate Level
Method resolution at compile time.
Q46. What is StringBuilder?
Intermediate Level
Mutable string class.
Q47. Difference between String and StringBuilder?
Intermediate Level
String immutable; StringBuilder mutable.
Q48. What is exception hierarchy?
Intermediate Level
Throwable → Exception → RuntimeException.
Q49. Checked vs unchecked exception?
Intermediate Level
Checked at compile-time; unchecked at runtime.
Q50. What is finally block?
Intermediate Level
Executes regardless of exception.
Q51. What is collection framework?
Intermediate Level
Set of classes for storing data.
Q52. Difference between List and Set?
Intermediate Level
List allows duplicates; Set does not.
Q53. What is ArrayList?
Intermediate Level
Resizable array implementation.
Q54. What is HashSet?
Intermediate Level
Stores unique elements.
Q55. What is HashMap?
Intermediate Level
Stores key-value pairs.
Q56. Difference between HashMap and Hashtable?
Intermediate Level
HashMap not synchronized; Hashtable is.
Q57. What is Iterator?
Intermediate Level
Used to traverse collections.
Q58. What is multithreading?
Intermediate Level
Executing multiple threads simultaneously.
Q59. What is thread lifecycle?
Intermediate Level
New, Runnable, Running, Waiting, Terminated.
Q60. What is synchronization?
Intermediate Level
Controls thread access to shared resources.
Q61. What is deadlock?
Intermediate Level
Threads waiting indefinitely for each other.
Q62. What is file handling?
Intermediate Level
Reading/writing files.
Q63. What is serialization?
Intermediate Level
Converting object into byte stream.
Q64. What is transient keyword?
Intermediate Level
Prevents serialization.
Q65. What is marker interface?
Intermediate Level
Interface without methods.
Q66. What is lambda expression?
Intermediate Level
Anonymous function implementation.
Q67. What is functional interface?
Intermediate Level
Interface with one abstract method.
Q68. What is stream API?
Intermediate Level
Processes collections functionally.
Q69. What is optional class?
Intermediate Level
Avoids null pointer exceptions.
Q70. What is forEach()?
Intermediate Level
Iterates over collection.
Q71. What is Comparable?
Intermediate Level
Defines natural ordering.
Q72. What is Comparator?
Intermediate Level
Defines custom ordering.
Q73. What is boxing?
Intermediate Level
Primitive to object conversion.
Q74. What is unboxing?
Intermediate Level
Object to primitive conversion.
Q75. What is enum?
Intermediate Level
Special class for constants.
Q76. What is switch expression?
Intermediate Level
Enhanced switch syntax.
Q77. What is Java memory model?
Advanced Level
Defines how threads interact through memory.
Q78. What is heap vs stack?
Advanced Level
Heap stores objects; stack stores method calls.
Q79. What is garbage collection?
Advanced Level
Automatic memory cleanup.
Q80. Types of GC?
Advanced Level
Serial, Parallel, CMS, G1.
Q81. What is JVM architecture?
Advanced Level
Class loader, runtime data areas, execution engine.
Q82. What is class loader?
Advanced Level
Loads classes into JVM.
Q83. What is reflection?
Advanced Level
Access class metadata at runtime.
Q84. What is proxy class?
Advanced Level
Dynamically generated class.
Q85. What is JIT compiler?
Advanced Level
Compiles bytecode into native code at runtime.
Q86. What is volatile keyword?
Advanced Level
Ensures visibility across threads.
Q87. What is atomic class?
Advanced Level
Provides lock-free thread-safe operations.
Q88. What is ForkJoinPool?
Advanced Level
Parallel task execution framework.
Q89. What is CompletableFuture?
Advanced Level
Asynchronous computation API.
Q90. What is reactive programming?
Advanced Level
Asynchronous data stream handling.
Q91. What is JDBC?
Advanced Level
Java API for database connectivity.
Q92. What is connection pool?
Advanced Level
Reuses database connections.
Q93. What is ORM?
Advanced Level
Maps objects to database tables.
Q94. What is Hibernate?
Advanced Level
ORM framework for Java.
Q95. What is Spring Framework?
Advanced Level
Enterprise Java framework.
Q96. What is dependency injection?
Advanced Level
Injecting objects instead of creating them.
Q97. What is Spring Boot?
Advanced Level
Simplifies Spring application setup.
Q98. What is microservices?
Advanced Level
Architecture with independent services.
Q99. What is REST API?
Advanced Level
Stateless web service architecture.
Q100. What is JWT?
Advanced Level
Token-based authentication.
Q101. What is thread pool?
Advanced Level
Manages multiple threads efficiently.
Q102. What is race condition?
Advanced Level
Threads accessing shared data incorrectly.
Q103. What is immutability?
Advanced Level
Object state cannot change.
Q104. What is design pattern?
Advanced Level
Reusable solution to common problem.
Q105. Explain Singleton pattern.
Advanced Level
Ensures one instance of class.
Q106. Explain Factory pattern.
Advanced Level
Creates objects without exposing logic.
Q107. Explain Observer pattern.
Advanced Level
Notifies changes to dependents.
Q108. What is SOLID principle?
Advanced Level
Design principles for maintainable code.
Q109. What is memory leak in Java?
Advanced Level
Unused objects retained in memory.
Q110. What is profiling?
Advanced Level
Analyzing performance issues.
Q111. What is JMX?
Advanced Level
Java management and monitoring.
Q112. What is native method?
Advanced Level
Method implemented in non-Java code.
Q113. What is GraalVM?
Advanced Level
High-performance JVM with polyglot support.
Q114. What is Java module system?
Advanced Level
Introduced in Java 9 for modular code.