Java Interview Questions
Java Interview Questions
Collections:
1. What is collection and its types
2. Difference between List, Set and Map. Explain which scenario you will use each
collection
3. Difference between ArrayList vs Vector
4. Difference between ArrayList vs LinkedList
5. Difference between HashSet vs TreeSet
6. Difference between HashSet vs LinkedHashSet
7. Difference between HashMap vs TreeMap
8. Difference between HashMap vs HashTable
9. What is concurrent hashmap
10. What is sysnchronized hashmap
11. Difference between concurrent hashmap vs synchronized hashmap
12. Internal working of HashMap
13. Internal working of HashSet
14. Difference between collection vs collections
15. How to create hashmap in synchronization
16. Fail fast and fail safe iterators
17. Difference between Iterator vs ListIterator
Java 8:
1. Java 8 features
2. What is streams API
3. Stream intermediate and terminal operation
4. difference between map and flatmap
5. difference between parellal stream and sequential stream
6. What is functional interface and examples of functional interface
7. Difference between default and static methods
8. What is predicate, function, consumer and supplier
9. What is lambda expression and how to implement that
10. What is optional class
11. What is method reference
12. What is java 8 memory changes
13. What is the change in hashmap in java 8
14. What are the new methods introduced in new datetime API
Threads:
1. What is thread
2. What is multithreading
3. How to create the thread
4. Thread lifecycle
5. What is Thread scheduler
6. What is Deadlock
7. What is Synchronization ans how to achieve this
8. What is Deamon Thread
Spring boot:
1. What is use of spring boot over spring
2. Advantages of spring boot
3. What is IOC container
4. What is dependency injection
5. Difference between bean factory vs application context
6. What is @SpringbootAApplication annotation
7. How auto configuration works internally
8. What is annotation and tell me annotaions which you know
9. What are the bean scopes
10. What is dispatcher servlet
11. Explain the spring mvc flow
12. Differene between @Controller and @RestController
13. How to convert object into json spring boot application
14. Difference between @GetMapping vs @RequestMapping
15. Difference between @PutMapping vs @PatchMapping
16. Difference between @RequestParam vs @PathVariable
17. Difference between @Component vs @Service
18. Difference between @Component vs @Bean
19. How Transaction management handled in Spring boot Application
20. How to handle exception in Spring Boot
21. Difference between @Qualifier vs @Primary
22. What is the use @Value
23. How many ways we can read application.properties file
24. What is spring profile
25. How to change default tomcat server into another server
26. How to configure two different database in a single spring boot application
27. What is @Autowired
28. Difference between SOAP vs REST
29. Tell me some Starter dependencies used in Spring boot application
30. What is the use of Actuator
31. Transaction management propagation and isolation
32. How to improve REST API perfomance
33. What is aspect oriented programming
Microservices:
1. How to communicate between two micsroservices
2. What is Microservices. explain how it differs from monolithic application
3. Microservices architecture
4. Mention the some of microservices design pattern
5. difference between CQRS patter vs SAGA pattern
6. How to handle microservices failure
7. What is circuit breaker
8. What is loadbalancer
9. What is cookies
Database:
1. Difference between JPA vs Hibernate
2. How to acheive one to one and one to many mapping in JPA
3. Difference between primary key vs Foreign key
4. Difference between primary key vs unique key
5. What is comosite key
6. How to define composite key in JPA
7. How to improve query performance
8. What is index
9. Difference between right join vs left join
10. Difference between get() vs load()
11. Difference between save() vs persist()
12. How to write native query
13.How to write custom query
14. Eager loading and lazy loading
15. Difference between first level cache vs Second level Cache
16. Difference between session vs session factory
17. n+1 problem in hibernate
18. What is stored procedure
Junit:
1. Difference between @Mock vs @Spy
2. Annotations used in test class
3. @Suite annotation
4. How to test private methods
Java programs:
1. Sort the array in reverse order
2. Find give number is lucky number (all intergers should be unique. EX. 5429 -
Lucky number, 54294 -not Lucky number)
3. Count the numbers in the given integer
4. Find first unique number of the given integer
5. Find min and max number of given array
6. Find second maximum salary of emloyee
7. Sort the employee based on salary
8. Find the sum of salary of the employees whose age is more than 30
9. Count the no of employees whose age is more then 30
10. Count the employees based on the age. (sample output: Age : 26, Count : 5,
Age : 27, Count : 10)
11. String palindrome
12. Find no of words given in the string
14. Reverse the words in the string
15. Find the duplicate character and its occurences in the string. (input:
stringinput. output: s-1,t-2,r-1,i-2,n-2,g-1,p-1,u-1)
16. Sort the hashmap based on the value.
17. Find the pairs whose sum is 6 in the given arraylist. (input: {1,2,3,4,5},
output: {1,5}, {2,4})