9 Java Interview Questions Indian Freshers Get Wrong
9 Java interview questions Indian freshers get wrong — with the deeper answers interviewers actually want on HashMap, OOP, multithreading, exceptions, and try-with-resources.

9 Java Interview Questions Indian Freshers Get Wrong
Java remains the most in-demand backend language in India by volume — IT services, banking, e-commerce, and enterprise companies all hire Java developers in large numbers. But most Indian freshers walk into Java interviews memorizing definitions without understanding the why behind each concept. Interviewers at TCS, Infosys, Wipro, and product companies like Flipkart and PhonePe don't want textbook answers. They want to see if you can explain trade-offs, write code on a whiteboard, and handle follow-up questions.
According to JavaCompiler.in's 2026 fresher interview analysis, OOP concepts appear in 90% of interviews, Collections in 85%, and multithreading in 70%. AmbitionBox and Naukri salary data shows Java fresher CTC ranges from ₹3.5-5 LPA at IT services to ₹6-10 LPA at product companies — and the candidates who answer these 9 questions well are the ones who land the higher end.
1. "What's the difference between == and .equals()?"
Most freshers say "== compares references, .equals() compares content." That's technically correct but incomplete. Interviewers follow up: "So why does == return true for two String literals with the same value?"
The answer: Java's String constant pool. When you write String a = "java"; String b = "java";, both point to the same pooled object — so a == b is true. But String c = new String("java") creates a separate heap object, so a == c is false even though a.equals(c) is true. The rule: always use .equals() for string comparison. Never rely on == — it works for pooled literals but breaks for dynamically created strings.
2. "Why are Strings immutable in Java?"
Freshers typically say "for security" and stop. The full answer has four pillars: security (strings carry file paths, URLs, and database credentials — if mutable, a malicious thread could change them mid-operation), thread safety (immutable objects are inherently safe to share across threads without synchronization), HashMap key caching (hashCode is computed once and cached, making lookups fast), and the String pool (the JVM can share one copy across references only because no one can modify it). Interviewers want to hear at least three of these.
3. "How does HashMap work internally?"
This is where most freshers collapse. They know HashMap stores key-value pairs but can't explain the internals. Here's what interviewers want:
HashMap uses an array of buckets. Each key's hashCode() determines the bucket index. If two keys hash to the same bucket (collision), entries are stored in a linked list. From Java 8 onward, if a bucket has more than 8 entries, the linked list converts to a balanced tree (O(log n) instead of O(n)). The default load factor is 0.75 — when the map is 75% full, it doubles in size and rehashes all entries.
Follow-up you'll get: "What happens if you don't override hashCode() when you override equals()?" Answer: two objects that are .equals() may land in different buckets, so HashMap can't find a key that's logically equal to one you stored. This breaks the equals/hashCode contract.
4. "What is the difference between ArrayList and LinkedList?"
Freshers memorize: "ArrayList uses array, LinkedList uses doubly-linked list." But interviewers ask: "When would you actually use LinkedList?"
ArrayList gives O(1) random access by index but O(n) insertion/deletion in the middle (it shifts elements). LinkedList gives O(1) insertion/deletion at a known node but O(n) random access. In practice, ArrayList is the right choice 95% of the time — CPU cache locality makes it faster even for many insertions. LinkedList is better only when you frequently add/remove from the ends or middle of a list you're already traversing with an iterator. Most Indian freshers overthink this and pick LinkedList for the wrong reasons.
5. "Explain method overloading vs overriding with an example"
Freshers confuse the two constantly. Overloading is compile-time polymorphism: same method name, different parameter list, in the same class. Overriding is runtime polymorphism: subclass redefines a parent method with the same signature. Key rules for overriding: you can't reduce visibility, you can't throw broader checked exceptions, and static methods can't be overridden (they're hidden, not overridden).
Interviewers test with a trick: "Can you overload a static method?" Yes. "Can you override a static method?" No — you can hide it, but that's not overriding. The @Override annotation won't compile on a static method pretending to override.
6. "What is the volatile keyword in Java?"
Most freshers skip this entirely or say "it makes variables thread-safe." That's dangerously incomplete. volatile ensures two things: visibility (when one thread writes a volatile variable, all threads immediately see the new value — no stale cached copies) and happens-before ordering (writes to volatile variables happen-before subsequent reads). But volatile does NOT provide atomicity. volatile int count = 0; with count++ from multiple threads is still a race condition because count++ is read-modify-write, not atomic. For atomic counters, use AtomicInteger.
7. "What happens when you create an object with new in Java?"
Freshers say "it allocates memory and calls the constructor." The full sequence: (1) JVM allocates memory on the heap for the object, (2) all instance fields are set to default values (0 for int, null for objects, false for boolean), (3) the constructor is called, which first calls super() (parent constructor), (4) instance initializers and variable initializers run in order, (5) the constructor body executes, (6) the reference is returned. Interviewers probe this to check if you understand object lifecycle — not just "new makes an object."
8. "What is the difference between checked and unchecked exceptions?"
Checked exceptions (IOException, SQLException) must be caught or declared with throws — the compiler enforces this. Unchecked exceptions (NullPointerException, ArrayIndexOutOfBoundsException) extend RuntimeException and don't require handling. The design philosophy: checked exceptions are for recoverable conditions (file not found, network timeout), unchecked for programming errors (null dereference, bad index).
Interviewers follow up: "Should you use checked or unchecked exceptions?" Modern Java practice favors unchecked exceptions for most application code — checked exceptions force try-catch boilerplate and don't compose well with lambdas and streams. Spring's data access layer converts all SQLExceptions to unchecked DataAccessException for this reason.
9. "What is try-with-resources? Why use it?"
Freshers know the syntax but can't explain why it's better than try-finally. Try-with-resources (Java 7+) automatically calls close() on any AutoCloseable resource — no matter if the try block completes normally or throws. It also handles suppressed exceptions: if both the try block and close() throw, the close exception is attached as a suppressed exception to the try exception, so you don't lose the root cause. With try-finally, the close() exception would mask the original exception. Always use try-with-resources for files, streams, database connections, and sockets.
How to Prepare for Java Interviews as an Indian Fresher
Don't just read question-answer lists. Interviewers at Indian companies test three things:
- Concept depth: Can you explain why, not just what? For every concept, prepare a "because" answer.
- Code on paper/whiteboard: TCS NQT and Infosys campus tests include coding rounds. Practice writing Java code by hand — no IDE autocomplete.
- Follow-up resilience: After you answer, they'll dig deeper. If you said "HashMap uses hashing," expect "explain collision handling." Prepare one level deeper than the standard answer.
Practice with PrepFox mock interviews to simulate real interview pressure — you'll discover which concepts you can explain clearly and which ones collapse under follow-up questions. Build your technical resume with the resume builder highlighting your Java projects, and get a resume review to ensure your skills section matches what Indian recruiters scan for. For more interview preparation strategies, read our complete interview preparation guide.
Bottom Line
The difference between a fresher who gets ₹3.5 LPA at TCS and one who gets ₹8 LPA at a product company isn't IQ — it's preparation depth. The 9 questions above are the ones that separate surface-level memorizers from candidates who actually understand Java. Pick three you're weakest at, go one level deeper than the standard answer, and practice explaining them out loud. That's how you crack Java interviews in India.
Ready to put this into practice?
Practice mock interviews, build your resume, and get expert feedback — all on PrepFox.
More from PrepFox Blog
How to Crack Aptitude Interview Questions in Placements
How to crack aptitude interview questions in Indian placements: quant, reasoning and verbal sections, an 8-week plan, and test-day strategy.
9 Questions to Ask the Interviewer That Impress HR
Interview questions to ask the interviewer: 9 smart questions that impress Indian HR, what each one signals, and what never to ask in round one.
How to Answer Civil Interview Questions as a Fresher
How to answer civil interview questions as a fresher in India: slump test, foundations, cement tests and salary data for site engineer offers.
