Java & Spring Interview Questions: What Really Happens Under the Hood There is a phase in every developer's career where you can use something without actually understanding what is happening underneath. You know how to use ConcurrentHashMap . You know what @Transactional does. You know that Spring injects dependencies. You know @SpringBootApplication starts your application. And then the interviewer asks: "Okay, but what actually happens internally?" Suddenly, knowing the syntax isn't enough. That is exactly what this blog is about. I'm going to break down some of the Java and Spring concepts that are frequently asked in interviews, but more importantly, I'll try to understand why they work the way they do . Let's start with one of my favourites. 1. ConcurrentHashMap in Java 8: What Actually Happens? Let's first establish the problem. A normal HashMap is not thread-safe. Imagine two threads doing this at the same time: map.put("A",...
Hello everyone! Hope you’re sipping your coffee just right—because I’ve brewed something equally strong for your brain. Welcome to a blog that dives into 5 deceptively tricky Java interview questions —the kind that test not just what you know, but how well you understand Java under the hood. If you, like me, share a love-hate relationship with this language, this blog might just hit home. So, let's get started... Question 1: What will be the output of the following code? Why? class Parent { static void staticMethod() { System.out.println("Static method in Parent"); } private void privateMethod() { System.out.println("Private method in Parent"); } void show() { staticMethod(); privateMethod(); } } class Child extends Parent { static void staticMethod() { System.out.println("Static method in Child"); } private void privateMethod() { System.out.println("Pr...