Java Programs-

 

1-Real-World JSON Parsing in Java (Complete Guide)

Java RealĀ  Question-

  1. Why does a Spring Boot app consume more memory over time?
  2. How do you detect bean initialization issues in large applications?
  3. What happens if @PostConstruct throws an exception?
  4. Why does @Value sometimes fail to inject properties?
  5. How does Spring Boot decide the order of auto-configurations?
  6. What are the risks of enabling too many Actuator endpoints?
  7. Why does your app behave differently after scaling pods?
  8. How does Spring Boot handle classpath scanning internally?
  9. What causes duplicate bean registration in multi-module projects?
  10. Why does your API return correct data but response time fluctuates?
  11. How do you control thread usage in Spring Boot applications?
  12. What happens when application.yml and application.properties both exist?
  13. Why do custom exception handlers sometimes not trigger?
  14. How do you handle large payloads without killing performance?
  15. Why does Hibernate generate unexpected queries?
  16. How do you debug a deadlock in a Spring Boot service?
  17. What happens if a BeanFactoryPostProcessor fails?
  18. How do you avoid startup failure due to missing configs?
  19. Why does Spring Boot retry DB connections on startup?
  20. How do you manage feature toggles safely?
  21. Why does @Cacheable sometimes not cache?
  22. How does Spring Boot isolate environment-specific configs?
  23. What causes classloader issues in fat JARs?
  24. How do you safely reload configs without restarting?
  25. Why does logging behave differently in prod vs local?
  26. How do you handle partial failures in dependent services?
  27. Your Spring Boot app works locally but fails after deployment. What are the first 3 things you check?
  28. A REST API is slow only in production, not locally. How do you debug it?
  29. You changed application.properties but changes are not reflecting. Why?
  30. Your Spring Boot service crashes under high traffic. What could be the reasons?
  31. Multiple beans of the same type exist and Spring throws an error. How do you fix it?
  32. You need different configs for dev, test, and prod. How will you design this?
  33. Your API works fine but returns 401 randomly. What could cause this?
  34. A database connection pool is getting exhausted. How do you identify and solve it?
  35. How do you handle API failures when calling another microservice?
  36. Your application memory usage keeps increasing over time. What do you suspect?
  37. How do you implement retry logic for failed REST calls?
  38. You deployed a new version but users still hit the old behavior. Why?
  39. How do you secure sensitive values like DB passwords in Spring Boot?
  40. What happens if @Transactional fails midway? How do you verify rollback?
  41. Your logs are missing in production. Where do you look?
  42. How do you handle versioning of REST APIs without breaking clients?
  43. One microservice is down and others are failing. How do you prevent this?
  44. How do you reduce startup time of a Spring Boot application?
  45. You need to execute code only once after application startup. How?
  46. How do you handle long-running background jobs in Spring Boot?
  47. What are SOLID principles?
  48. What is OOPs in Java?
  49. Which Redis version are you currently using?
  50. What is socket programming in Java?
  51. What is multithreading?
  52. When should we override equals() and hashCode()?
  53. What is immutability in Java?
  54. What is synchronization in Java?
  55. What is the Singleton design pattern?
  56. What are the types of Singleton?
  57. Where do we use Eager, Lazy, Thread-safe, Double-checked locking, and Enum Singleton?
  58. If we have multiple catch blocks (one for Exception and one for a custom exception), what will happen?
  59. Difference between Hashtable and ConcurrentHashMap?
  60. What is a Consumer functional interface in Java 8?
  61. What is a Predicate functional interface?
  62. Purpose of default methods in functional interfaces?
  63. What is backward compatibility in Java?
  64. Difference between collect() and reduce() in Stream API?
  65. If a Kafka producer publishes to a topic, how does a consumer consume data?
  66. What is CompletableFuture?
  67. How do you group and sum data using Stream API?
  68. Can you explain Stream API code line by line?
  69. How do you make parallel service calls using CompletableFuture?
  70. How do you handle a shared counter using multiple threads?
  71. Difference between sleep(), wait(), and notify()?
  72. What is Thread.yield()?
  73. Metaspace vs. PermGen: Since Java 8, PermGen is gone. Explain how Metaspace works and how it handles class metadata memory allocation differently from the Heap.
  74. Weak vs. Soft References: In the context of building a caching library, when would you strictly use SoftReference over WeakReference?
  75. The volatile Keyword: Does volatile guarantee atomicity? Explain “happens-before” relationship in the context of the Java Memory Model (JMM).
  76. ThreadLocal Usage: How does ThreadLocal work internally? Why is it a common source of memory leaks in web containers (like Tomcat)?
  77. CompletableFuture: Scenario: You need to fetch data from 3 different microservices (User, Orders, Payments) asynchronously and combine the result. Write a snippet using CompletableFuture.allOf().
  78. Deadlock Prevention: Given a banking system where Account A transfers to Account B, write a thread-safe transfer method that prevents deadlock if two threads try to transfer (A->B and B->A) simultaneously.
  79. N+1 Problem: What is the N+1 select problem in Hibernate/JPA? How do @EntityGraph or JOIN FETCH solve it?
  80. Optimistic vs. Pessimistic Locking: You are designing a ticket booking system. Which locking strategy would you use for seat selection and why?
  81. Connection Pooling: What are the critical configuration parameters in HikariCP (e.g., maximumPoolSize, connectionTimeout)?
  82. Records: How do Java Records differ from standard POJOs regarding immutability and equals()/hashCode() generation?
  83. Virtual Threads (Project Loom): How do Virtual Threads differ from Platform Threads? Why are they better for I/O-heavy workloads?
  84. Pattern Matching for switch cases: Explain how pattern matching enhances switch in newer Java versions.
  85. HashMap collision: Explain the transition from LinkedList to Red-Black Tree in a HashMap bucket (Java 8+). What is the threshold?
  86. ConcurrentHashMap: How does ConcurrentHashMap achieve thread safety without locking the entire map? Explain the concept of “Segment Locking” (pre-Java 8) vs. CAS + synchronized (Java 8+).
  87. PriorityQueue: Implement a “Top K Elements” logic using a PriorityQueue. What is the time complexity of insertion and removal?
  88. Bean Lifecycle: Explain the order of execution: Constructor, Setter, @PostConstruct, BeanPostProcessor.
  89. Circular Dependencies: How does Spring Boot handle circular dependencies (A depends on B, B depends on A)? What is the difference between constructor injection and setter injection in this context?
  90. Transactional Propagation: Explain the difference between PROPAGATION_REQUIRED and PROPAGATION_REQUIRES_NEW.