Interview Questions
Interview Questions
5. What is the difference between a local variable, an instance variable, and a class
variable?
OOPs Concepts
Exception Handling
Collections Framework
Java 8 Features
28. How does the Stream API work? Provide a use case.
31. How does Java manage memory internally (Heap & Stack)?
33. Explain the difference between strong, weak, soft, and phantom references in Java.
34. What are memory leaks in Java? How can they be prevented?
37. Explain the different JVM memory areas (Heap, Stack, Metaspace, etc.).
Miscellaneous
14. How do you handle exceptions in a Spring Boot REST API (@ControllerAdvice and
@ExceptionHandler)
15. How can you enable CORS (Cross-Origin Resource Sharing) in Spring Boot?
17. What is Spring Security, and how do you configure it in Spring Boot?
18. How can you secure REST APIs using JWT (JSON Web Token)?
20. What is OAuth2, and how do you integrate it with Spring Boot?
29. How can you improve the performance of a Spring Boot application?
1. Microservices Basics
39. What is Service Discovery, and how does Eureka work in Spring Boot?
40. What are Kafka and RabbitMQ? How are they used in Microservices?
55. What are the best practices for database management in Microservices?
60. What is ELK (Elasticsearch, Logstash, Kibana), and how does it help in
Microservices logging
3. Write a Java 8 program to find the sum of all even numbers in a list using lambda and
streams
14. Use Optional to filter a list and return the first matching element.
15. Write a program to check if a value is present in an Optional and print it.
23. Write a Java 8 program to group a list of employees by department using Streams.
24. Convert a List<String> to a Map<String, Integer> where the key is the string and the
value is its length.
28. Convert a list of objects into a Map where the key is an ID and the value is the object.
29. Partition a list of numbers into even and odd using Collectors.partitioningBy().
32. Write a Java 8 program to sort a large list using parallel streams.
34. Find the sum of squares of all numbers in a list using parallel streams.
35. Write a program to demonstrate the difference between parallel() and sequential()
streams.
36. Write a Java 8 program to get the current date and time.