0% found this document useful (0 votes)
0 views8 pages

Interview Questions

The document is a comprehensive list of interview questions covering Java basics, OOP concepts, exception handling, collections framework, multithreading, Java 8 features, memory management, JVM internals, and Spring Boot, including microservices architecture and security. It includes practical programming tasks related to Java 8 features such as lambda expressions and streams. The content is structured into sections that facilitate understanding of both theoretical and practical aspects of Java and Spring Boot.

Uploaded by

yvani2304
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)
0 views8 pages

Interview Questions

The document is a comprehensive list of interview questions covering Java basics, OOP concepts, exception handling, collections framework, multithreading, Java 8 features, memory management, JVM internals, and Spring Boot, including microservices architecture and security. It includes practical programming tasks related to Java 8 features such as lambda expressions and streams. The content is structured into sections that facilitate understanding of both theoretical and practical aspects of Java and Spring Boot.

Uploaded by

yvani2304
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
You are on page 1/ 8

Java Basics

1. What is the difference between JDK, JRE, and JVM?

2. How does Java achieve platform independence?

3. Explain the differences between == and .equals() in Java.

4. Why is Java not considered 100% object-oriented?

5. What is the difference between a local variable, an instance variable, and a class
variable?

OOPs Concepts

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

7. How does Java support multiple inheritance?

8. What is method overloading and method overriding? Provide examples.

9. What is dynamic method dispatch in Java?

10. Explain the concept of abstraction with an example.

Exception Handling

11. What is the difference between Checked and Unchecked exceptions?

12. What happens if an exception is thrown in a finally block?

13. What is the difference between throw and throws?

14. How does Java’s exception propagation work?

15. How to create a custom exception in Java?

Collections Framework

16. What is the difference between ArrayList and LinkedList?

17. How does HashMap work internally in Java?


18. What are fail-fast and fail-safe iterators?

19. How does ConcurrentHashMap prevent race conditions?

20. What is the difference between HashSet and TreeSet?

Multithreading & Concurrency

21. What is the difference between Runnable and Callable?

22. How does the synchronized keyword work in Java?

23. What are volatile and transient keywords?

24. Explain the difference between ReentrantLock and synchronized.

25. What are the differences between Thread.sleep() and wait()?

Java 8 Features

26. What are functional interfaces? Name some examples.

27. Explain Lambda expressions with an example.

28. How does the Stream API work? Provide a use case.

29. What is the purpose of the Optional class in Java 8?

30. What is the difference between map() and flatMap() in Streams?

Memory Management & Performance

31. How does Java manage memory internally (Heap & Stack)?

32. What is garbage collection, and how does it work in Java?

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?

35. How does StringBuilder help improve performance compared to String?


JVM Internals

36. What are different types of class loaders in Java?

37. Explain the different JVM memory areas (Heap, Stack, Metaspace, etc.).

38. What is the purpose of the Just-In-Time (JIT) compiler?

39. What are the different types of Garbage Collectors in Java?

40. How does the interning of strings work in Java?

Miscellaneous

41. What is immutability in Java? How is String immutable?

42. What is the difference between Comparable and Comparator?

43. Explain design patterns you have used in your project.

44. How do you prevent deadlocks in Java?

45. What is the difference between serialization and deserialization.

Spring Boot Interview Questions

1. Spring Boot Basics

1. What is Spring Boot, and how is it different from Spring Framework?

2. What are the main features of Spring Boot?

3. Explain the purpose of the @SpringBootApplication annotation.

4. What is the role of application.properties and application.yml?

5. How does Spring Boot handle dependency management?

2. Dependency Injection & Annotations

6. What is dependency injection in Spring Boot?

7. What is the difference between @Component, @Service, and @Repository?

8. What is @Autowired, and how does it work?

9. What is the difference between @Primary and @Qualifier?

10. What is the purpose of the @Bean annotation?


3. Spring Boot REST APIs

11. What is @RestController, and how is it different from @Controller?

12. Explain how to create a RESTful API in Spring Boot.

13. What is @RequestMapping, and how is it different from @GetMapping and


@PostMapping?

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?

4. Spring Boot Security

16. How do you implement authentication and authorization 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)?

19. How do you define role-based access control in Spring Security?

20. What is OAuth2, and how do you integrate it with Spring Boot?

5. Spring Boot JPA & Database

21. What is Spring Data JPA?

22. How does @Entity differ from @Table in JPA?

23. What is CrudRepository, JpaRepository, and PagingAndSortingRepository?

24. How do you write a custom query in Spring Data JPA?

25. What is the difference between fetch = FetchType.LAZY and fetch =


FetchType.EAGER?

6. Spring Boot Caching & Performance

26. How do you enable caching in Spring Boot?

27. What is @Cacheable, and how does it work?


28. What is the purpose of @Async in Spring Boot?

29. How can you improve the performance of a Spring Boot application?

30. What is Actuator in Spring Boot? How do you enabled

Microservices Interview Questions

1. Microservices Basics

31. What is Microservices architecture?

32. What are the advantages and disadvantages of Microservices?

33. How is Monolithic architecture different from Microservices?

34. What are the key components of a Microservices architecture?

35. What is the role of the API Gateway in Microservices?

2. Communication Between Microservices

36. How do microservices communicate with each other?

37. What is synchronous vs. asynchronous communication in microservices?

38. What is Feign Client, and how does it work?

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?

3. Service Discovery & Load Balancing

41. What is Netflix Eureka, and how does it work?

42. What is Spring Cloud Load Balancer?

43. What is Ribbon, and how does it work?

44. How do you handle failures in Microservices (Circuit Breaker Pattern)?

45. What is Resilience4j, and how is it different from Hystrix?

4. API Gateway & Security

46. What is API Gateway in Microservices?


47. What is Spring Cloud Gateway?

48. How do you secure Microservices?

49. What is OAuth2, and how is it used in Microservices?

50. How do you implement rate limiting in API Gateway?

5. Database & Transactions in Microservices

51. How do you handle distributed transactions in Microservices?

52. What is the Saga pattern, and how does it work?

53. What is an event-driven architecture in Microservices?

54. How do you ensure data consistency across Microservices?

55. What are the best practices for database management in Microservices?

6. Monitoring & Logging

56. What tools can be used to monitor Microservices?

57. What is centralized logging in Microservices?

58. How does Spring Boot Actuator help in monitoring Microservices?

59. What is Prometheus, and how does it work?

60. What is ELK (Elasticsearch, Logstash, Kibana), and how does it help in
Microservices logging

1. Write a Java 8 program to sort a list of strings using lambda expressions

2. Create a functional interface and use it with a lambda expression.

3. Write a Java 8 program to find the sum of all even numbers in a list using lambda and
streams

4. Implement a custom Comparator using a lambda expression.

5. Convert a List<String> to uppercase using Java 8 Streams and lambda.


6. Write a Java 8 program to count the number of elements in a list that start with a
specific letter.

7. Find the second highest number in a list using Streams.

8. Remove duplicate elements from a list using Streams.

9. Convert a List<Integer> to a List<String> using Streams.

10. Find the longest string in a list using Streams.

11. Write a Java 8 program to avoid NullPointerException using Optional.

12. How do you return a default value when an Optional is empty?

13. Convert an Optional<String> to Optional<Integer>.

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.

16. Use Predicate to filter even numbers from a list.

17. Implement Consumer to print all elements of a list.

18. Use Function to convert a list of names into uppercase.

19. Use Supplier to generate a random number.

20. Chain multiple functional interfaces together in a Stream pipelines

21. Write a Java 8 program to transform a List<List<Integer>> into a single List<Integer>


using flatMap().

22. Convert a Map<String, List<Integer>> into a List<Integer> using Streams.

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.

25. Flatten a Map<String, List<String>> into a List<String> using flatMap().

26. Group a list of employees by their department using Collectors.groupingBy().

27. Find the average salary of employees in each department using


Collectors.averagingDouble().

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().

30. Concatenate all strings in a list using Collectors.joining().


31. Convert a normal Stream to a Parallel Stream and measure its performance.

32. Write a Java 8 program to sort a large list using parallel streams.

33. Compare performance between forEach() and parallelStream().forEach().

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.

37. Calculate the difference between two dates using ChronoUnit.

38. Convert LocalDate to LocalDateTime and vice versa.

39. Format a date using DateTimeFormatter.

40. Add 7 days to the current date using LocalDate

You might also like