0% found this document useful (0 votes)
10 views5 pages

Java Interview Questions and Answers

The document contains a comprehensive list of Java interview questions categorized into various topics including Exception Handling, Array and ArrayList, Collection Framework, Spring Boot, OOP concepts, JVM, JDK, JRE, Garbage Collection, Multithreading, and Concurrency. It also provides a structure for answering the common interview question 'Tell Me About Yourself' along with a sample answer and key tips for interviews. The questions cover fundamental concepts and practical applications relevant to Java development.

Uploaded by

adityamauryz909
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Java Interview Questions and Answers

The document contains a comprehensive list of Java interview questions categorized into various topics including Exception Handling, Array and ArrayList, Collection Framework, Spring Boot, OOP concepts, JVM, JDK, JRE, Garbage Collection, Multithreading, and Concurrency. It also provides a structure for answering the common interview question 'Tell Me About Yourself' along with a sample answer and key tips for interviews. The questions cover fundamental concepts and practical applications relevant to Java development.

Uploaded by

adityamauryz909
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA INTERVIEW QUESTIONS

A. Exception Handling (Core Java)

1. What is Exception Handling in Java?


2. What is the difference between Checked and Unchecked exceptions?
3. What are the keywords used in Exception Handling?
4. What is the purpose of try and catch block?
5. What is finally block and when it is executed?
6. Can a try block exist without a catch block?
7. Can we have multiple catch blocks for a single try block?
8. What is the difference between throw and throws?
9. What happens if an exception is not handled in Java?
10. What is a custom exception?
11. What is the difference between Error and Exception?
12. Can we use multiple catch blocks for the same exception?
13. Can finally block be skipped?
14. What is the use of Throwable class in Java?
15. What is the difference between RuntimeException and CompileTimeException?

B. Array and ArrayList

16. What is an array in Java?


17. What are the limitations of arrays in Java?
18. What is the default value of an array element?
19. Can an array hold different data types in Java?
20. How to find the length of an array?
21. What is ArrayIndexOutOfBoundsException?
22. What is an ArrayList in Java?
23. How is ArrayList different from Array?
24. What are the main methods of ArrayList class?
25. How can you remove an element from an ArrayList?
26. How can you sort an ArrayList in Java?
27. Can ArrayList store null values?
28. What is the difference between ArrayList and LinkedList?
29. How can you convert an array to an ArrayList?
30. How can you convert an ArrayList back to an array?

C. Collection Framework

31. What is the Collection Framework in Java?


32. What are the main interfaces in the Collection Framework?
33. What is the difference between List, Set, and Map?
34. What is the difference between HashSet and TreeSet?
35. What is HashMap in Java?
36. What is the difference between HashMap and Hashtable?
37. What is the difference between HashMap and LinkedHashMap?
38. What is the difference between HashMap and TreeMap?
39. What is Iterator in Java?
40. What is the difference between Iterator and ListIterator?
41. What is ConcurrentModificationException?
42. What is the difference between fail-fast and fail-safe iterators?
43. What is the difference between Collection and Collections class?
44. How can you synchronize a Collection in Java?
45. What are the advantages of using the Collection Framework?

D. Spring Boot

46. What is Spring Boot?


47. What are the advantages of Spring Boot?
48. What is the difference between Spring and Spring Boot?
49. What is the purpose of [Link] file in Spring Boot?
50. What are the commonly used annotations in Spring Boot?

E. OOPs Concepts (Object-Oriented Programming)

51. What are the main principles of Object-Oriented Programming?


52. What is the difference between class and object?
53. What is encapsulation in Java?
54. What is inheritance in Java?
55. What is polymorphism in Java?
56. What is abstraction in Java?
57. What is the difference between abstraction and encapsulation?
58. What is method overloading?
59. What is method overriding?
60. What is the difference between compile-time and runtime polymorphism?
61. What is the difference between this and super keyword?
62. Can we overload a main() method in Java?
63. Can we override a static method?
64. What are constructors in Java?
65. What is the difference between default and parameterized constructors?
66. Can we call one constructor from another in Java?
67. What is the use of the final keyword in Java?
68. What is the difference between an abstract class and an interface?
69. Can an interface have a constructor?
70. What is multiple inheritance and is it supported in Java?
71. What is the difference between IS-A and HAS-A relationship?
72. What are access modifiers in Java and what are their scopes?
73. What is the difference between static and non-static members?
74. What is the purpose of the ‘this’ keyword?
75. What is the difference between shallow copy and deep copy?

F. JVM, JDK, and JRE

76. What is JVM in Java?


77. What is the role of the JVM in Java execution?
78. What is JRE in Java?
79. What is JDK in Java?
80. What is the difference between JDK, JRE, and JVM?
81. What are the main components of JVM?
82. What is the Just-In-Time (JIT) compiler?
83. What is the role of the ClassLoader in Java?
84. What is the Execution Engine in JVM?
85. What is the difference between heap memory and stack memory in JVM?
86. What is a ClassLoader and how does it work?
87. How does the JVM manage memory internally?
88. What happens when you run a Java program internally?
89. What is bytecode in Java?
90. How does JVM ensure platform independence?

G. Garbage Collection and Memory Management

91. What is Garbage Collection in Java?


92. Why is garbage collection necessary?
93. How does garbage collection work in Java?
94. What are different types of garbage collectors available in Java?
95. What is the difference between minor GC and major GC?
96. Can you force garbage collection in Java?
97. What is finalize() method and is it recommended for use?
98. What are memory leaks in Java?
99. How can you reduce memory leaks in Java applications?
100. What is the difference between strong, weak, soft, and phantom references in
Java?

H. Multithreading and Concurrency


101. What is a thread in Java?
102. What is the difference between a process and a thread?
103. How can you create a thread in Java?
104. What is the difference between extending Thread class and implementing
Runnable interface?
105. What is the lifecycle of a thread in Java?
106. What is the difference between start() and run() method?
107. What is the purpose of the join() method?
108. What is thread synchronization?
109. What is the difference between synchronized method and synchronized block?
110. What is inter-thread communication?
111. What are wait(), notify(), and notifyAll() methods used for?
112. What is the difference between sleep() and wait()?
113. What is a daemon thread?
114. What is thread priority and how can it be set?
115. What is a race condition in multithreading?
116. What is deadlock in Java multithreading?
117. How can you avoid deadlock?
118. What is a volatile variable in Java?
119. What is the use of the synchronized keyword?
120. What is the difference between Concurrency and Parallelism?
121. What is the Executor framework in Java?
122. What is Callable and Future in Java?
123. What is ThreadPoolExecutor?
124. What is the difference between submit() and execute() in ExecutorService?
125. What is ReentrantLock in Java concurrency?
126. What is the difference between synchronized and Lock interface?
127. What is the ConcurrentHashMap and how is it different from HashMap?
128. What is the Fork/Join framework in Java?
129. What is the use of Atomic classes in Java concurrency package?
130. What is the difference between BlockingQueue and ConcurrentLinkedQueue?

How to Answer: “Tell Me About Yourself”:


1. Structure of the Answer

Use this simple 4-part structure:

1. Introduction – Who you are & your background


2. Technical Skills – What technologies you work on
3. Project/Experience – Where and how you used your skills
4. Career Goal – What you are looking for next

2. Sample Answer

“Thank you for the opportunity to introduce myself.


My name is [Your Name], and I am a passionate Java Developer with a strong foundation in
Core Java, Object-Oriented Programming, and backend development using the Spring Boot
framework.
I have hands-on experience working with Java 8+, Spring Boot, RESTful APIs,
Hibernate/JPA, and MySQL. I am also familiar with tools like Maven, Git, and Postman, and
I have a basic understanding of microservices architecture and deployment using Spring
Boot.

In my recent project, I developed a web-based application using Spring Boot and MySQL
that focused on user management and authentication. I worked on creating REST APIs,
handled exception management, and implemented CRUD operations with proper validations
and service layers.

I enjoy solving complex coding problems and optimizing performance using clean and
maintainable code. I am continuously improving my skills in backend development and
learning about new technologies like Spring Security and Docker for deployment.

Currently, I am looking for an opportunity where I can contribute my technical knowledge,


grow as a backend developer, and work on real-world scalable applications using Java and
Spring Boot.”

3. Key Tips for Interview

• Keep it under 2 minutes.


• Avoid reciting your resume word-for-word.
• Focus on skills relevant to the role (Java, Spring Boot, API, MySQL, etc.).
• End with a positive future goal — “looking for an opportunity to contribute and
grow.”

You might also like