Java interview questions for freshers cover OOP pillars, core Java concepts, exception handling, and the collection framework. Experienced candidates face questions on JVM internals, garbage collection, and concurrency. This guide covers both levels with concise, interview-ready answers you can say out loud in any campus placement or off-campus drive.
Quick Answer: What Java Topics Do Freshers Get Asked?
- OOP concepts: inheritance, polymorphism, encapsulation, abstraction
- Core Java: access modifiers, final keyword, static vs instance, String immutability
- Exception handling: checked vs unchecked, try-catch-finally
- Collections: ArrayList, HashMap, HashSet and when to use each
- Java 8 basics: lambdas, streams, Optional
- Freshers should focus on OOP pillars, data types, access modifiers, and basic collection classes like ArrayList and HashMap.
- Experienced developers get quizzed on thread safety, memory management, JVM tuning, and Java 8+ features like streams and lambdas.
- HashMap internals, including hashing, collision resolution, and load factor, come up at every experience level.
- The Java collection framework is the single most tested topic in Indian product and service company interviews, from TCS and Infosys to Flipkart and Zepto.
- Structured, topic-by-topic preparation over four to six weeks consistently outperforms last-minute cramming.
Java Interview Questions for Freshers: Core Java and OOP
If you’re sitting a campus placement or your first off-campus drive, interviewers want to confirm you understood what you studied, not just memorised it. The questions stay close to your syllabus but with a twist: they want you to explain, not just define. Java interview questions for freshers almost always start with OOP before moving to collections and exception handling.
OOP Concepts Every Fresher Must Know
What is the difference between abstraction and encapsulation? Abstraction hides implementation details and shows only functionality. Encapsulation bundles data and methods into a single unit and restricts direct access using access modifiers. A class is encapsulation in action; an interface or abstract class demonstrates abstraction.
What is method overloading vs method overriding? Overloading is compile-time polymorphism: same method name, different parameters, same class. Overriding is runtime polymorphism: same method signature, different class in an inheritance hierarchy. Interviewers at companies like Wipro and Cognizant ask this in almost every fresher round.
What is the difference between an abstract class and an interface? An abstract class can have constructors, instance variables, and concrete methods. An interface (pre-Java 8) could only have abstract methods. From Java 8 onward, interfaces support default and static methods. Use an abstract class when classes share state; use an interface to define a contract.
Exception Handling and Memory Basics
What is the difference between checked and unchecked exceptions? Checked exceptions are verified at compile time, like IOException and SQLException. Unchecked exceptions, like NullPointerException and ArrayIndexOutOfBoundsException, are caught only at runtime. You must handle or declare checked exceptions; unchecked ones are optional to catch.
What does the final keyword do? Applied to a variable, it makes it a constant. Applied to a method, it prevents overriding. Applied to a class, it prevents inheritance. The String class in Java is final, which is why strings are immutable.
According to the TIOBE Index (June 2025), Java ranks among the top three most used programming languages globally, which explains why it dominates technical screening rounds at Indian IT companies and startups alike.
Java Collections Interview Questions
The collection framework is where most candidates lose marks in java interview questions for freshers and experienced rounds alike. It is not enough to list the classes. You need to know when to use which one and why the performance characteristics differ.
Most Commonly Asked Java Collections Interview Questions
ArrayList vs LinkedList: ArrayList uses a dynamic array internally; random access is O(1). LinkedList uses a doubly linked list; insertion and deletion in the middle are O(1) but traversal is O(n). For most read-heavy use cases, ArrayList wins. For frequent insertions at arbitrary positions, LinkedList is better.
HashSet vs TreeSet vs LinkedHashSet: HashSet gives O(1) average for add and contains but no ordering guarantee. TreeSet maintains natural or custom sort order with O(log n) operations. LinkedHashSet preserves insertion order with O(1) average performance. Pick based on whether you need ordering or pure speed.
HashMap vs Hashtable vs ConcurrentHashMap: Hashtable is synchronised and thread-safe but slow. HashMap is unsynchronised and faster but not thread-safe. ConcurrentHashMap uses segment-level locking (Java 7) or a compare-and-swap mechanism (Java 8+) to give thread safety without the bottleneck of full synchronisation. In production code, ConcurrentHashMap is the standard choice for multi-threaded environments.
HashMap Internals: What Interviewers Actually Want
HashMap stores key-value pairs in an array of Node objects called buckets. When you call put(key, value), Java computes the key’s hash code, applies a secondary hash function to reduce collisions, and determines the bucket index using (n-1) & hash where n is the array capacity.
If two keys map to the same bucket (a collision), Java uses a linked list to chain the entries. From Java 8 onward, when a bucket’s linked list exceeds eight entries and the total map size exceeds 64, that list converts to a red-black tree, bringing worst-case lookup from O(n) to O(log n).
The default initial capacity is 16 and the default load factor is 0.75. When the number of entries exceeds capacity x load factor, HashMap resizes by doubling its array and rehashing all entries. This rehashing is expensive, so if you know your data volume upfront, initialise with a capacity of (expected entries / 0.75) + 1 to avoid it.
| Collection Class | Thread Safe? | Allows Null Keys? | Order Guaranteed? | Average Time Complexity |
|---|---|---|---|---|
| HashMap | No | Yes (one null key) | No | O(1) |
| LinkedHashMap | No | Yes (one null key) | Insertion order | O(1) |
| TreeMap | No | No | Sorted order | O(log n) |
| Hashtable | Yes | No | No | O(1) |
| ConcurrentHashMap | Yes | No | No | O(1) |
Java Interview Questions for Experienced Developers
If you have two or more years of experience, expect the conversation to move well beyond syntax. Interviewers at product companies like PhonePe, Swiggy, and CRED want to know how you think about system behaviour, not just what you can code.
JVM Internals and Garbage Collection
The JVM divides heap memory into Young Generation, Old Generation, and (pre-Java 8) PermGen or (Java 8+) Metaspace. New objects are allocated in Eden space. Minor GC runs frequently on the Young Generation. Objects that survive multiple minor GC cycles get promoted to Old Generation, where Major GC runs less frequently but takes longer.
Interviewers ask about GC algorithms. G1GC (Garbage First) is the default from Java 9 onward. ZGC and Shenandoah target ultra-low pause times, under 10 milliseconds even on multi-terabyte heaps, making them relevant for latency-sensitive financial and e-commerce systems. According to Oracle’s Java SE documentation (Java 15 release notes), ZGC has been production-ready since Java 15.
Common JVM tuning flags you should know:
- -Xms and -Xmx: initial and maximum heap size
- -XX:+UseG1GC: enable G1 garbage collector
- -XX:MaxGCPauseMillis: target maximum GC pause time
- -XX:+PrintGCDetails: log GC events for analysis
Java Multithreading Interview Questions
The synchronized keyword acquires an intrinsic lock on an object, ensuring only one thread executes a block at a time. It is correct but coarse-grained. The java.util.concurrent package gives you finer tools: ReentrantLock for explicit locking with tryLock support, Semaphore for controlling access to a pool of resources, and CountDownLatch for coordinating thread startup.
The Java Memory Model (JMM) defines how threads interact through memory. The volatile keyword ensures visibility: writes to a volatile variable are immediately visible to other threads. It does not ensure atomicity, though. For compound actions like increment, use AtomicInteger or explicit synchronisation.
A 2024 survey by JetBrains covering over 26,000 developers globally found that 69% of Java developers use Java 11 or higher in production, with Java 17 (LTS) being the most common target version. Knowing Java 8 features like streams and lambdas is baseline; knowing Java 17 features like records, sealed classes, and pattern matching distinguishes experienced candidates.
Java 8 Interview Questions: Streams, Lambdas, and Optional
Streams API: Streams allow declarative, pipeline-style processing of collections. They are lazy: intermediate operations like filter and map do not execute until a terminal operation like collect or forEach is called. Parallel streams split work across the ForkJoinPool, but they add overhead and are not always faster for small datasets.
Optional: Optional wraps a potentially null value and forces you to handle the null case explicitly. It reduces NullPointerException risk in API design. Use it as a return type, not as a field or parameter type.
If you are also preparing for roles in tech-adjacent fields, the cybersecurity interview questions guide and the data analyst interview questions resource on 3.0 University cover similar depth for those tracks.
How Freshers Should Prepare for Java Interview Questions
Four to six weeks of structured preparation is realistic for most college students and recent graduates. The mistake most people make is reading theory without writing code. Interviewers can tell the difference immediately. Treating java interview questions for freshers as a topic-by-topic checklist rather than a random list is what separates prepared candidates from the rest.
A Week-by-Week Java Interview Study Plan
- Week 1: OOP concepts, access modifiers, static vs instance, constructors, the this and super keywords. Write at least one small program per concept.
- Week 2: Exception handling, String class internals, wrapper classes, autoboxing, and Java I/O basics.
- Week 3: The full collection framework: List, Set, Map, Queue. Understand time complexity, not just usage. Solve 10 LeetCode easy problems using Java collections.
- Week 4: Multithreading basics: Thread class, Runnable, synchronisation, and the Executor framework. Java 8 features: lambdas, streams, and method references.
- Week 5-6: Mock interviews. Record yourself answering questions. Review your answers against this guide. Fix gaps.
Skills like version control with Git, basic SQL, and REST API concepts make your profile stronger even at the fresher level. The top skills every college student must learn before graduation covers exactly this combination. If you are still deciding which technical path to pursue, the career path guide for graduates in 2026 gives a practical framework.
According to NASSCOM’s India Tech Talent Report 2024, Java remains one of the top three demanded skills in Indian IT hiring, with demand concentrated in Bengaluru, Hyderabad, Pune, and Chennai. Getting the fundamentals right opens doors at both service companies like TCS and Infosys and product startups in the same cities.
If you want to invest in structured learning, the top online courses for high-salary jobs in 2025 lists verified options across tech domains. For a broader view of what certifications actually move the needle, the 3.0 University courses page covers programmes in Cybersecurity, Ethical Hacking, AI, and Blockchain that complement a Java development background.
Roles that combine Java skills with security knowledge, like application security engineers, are growing fast. Understanding what that career looks like is worth a few minutes on the cybersecurity analyst career guide.
The best next step this week is to pick one topic per day, write actual code, and explain it out loud as if you are in an interview. That combination of writing and verbalising is what builds real recall under pressure.
Frequently Asked Questions
What Java questions are asked to freshers?
Freshers face questions on OOP pillars (inheritance, polymorphism, encapsulation, abstraction), data types, access modifiers, exception handling, String vs StringBuilder, and basic collection classes like ArrayList and HashMap. Interviewers at Indian IT companies like TCS, Infosys, and Wipro also test simple coding problems involving loops, arrays, and basic sorting logic.
Is Java good for freshers to learn for placements?
Yes. Java is one of the most in-demand languages in Indian campus placements and off-campus drives. Its strong OOP foundation, wide use in enterprise and product companies, and extensive interview question bank make it one of the safest and highest-return languages a fresher can prepare in.
Which Java version should freshers prepare for interviews?
Freshers should be comfortable with Java 8 features like lambdas, streams, and Optional, as these appear in most fresher and mid-level rounds. Understanding Java 11 and Java 17 LTS features like records and sealed classes is a bonus that distinguishes candidates at product companies.
How long does Java interview preparation take for freshers?
A focused four to six week plan is enough for most freshers to cover OOP, exception handling, the full collection framework, basic multithreading, and Java 8 features. Writing code daily and doing mock interviews in the final week is more effective than reading alone.
What collection framework questions come up most?
The most common Java collection framework interview questions cover ArrayList vs LinkedList, HashMap vs Hashtable vs ConcurrentHashMap, HashSet vs TreeSet, and Iterator vs ListIterator. Interviewers also ask about fail-fast vs fail-safe iterators, the difference between Comparable and Comparator, and how to choose the right collection for a given use case.
How do you explain HashMap internals in an interview?
Say this: HashMap stores entries in an array of Node buckets. It computes the key’s hash, finds the bucket index using bitwise AND, and chains collisions in a linked list. From Java 8, lists with more than 8 entries convert to a red-black tree. The default load factor is 0.75; exceeding it triggers a resize and full rehash.
What Java questions are asked to experienced developers?
Experienced developers are tested on JVM memory model, garbage collection algorithms (G1GC, ZGC), thread safety with ConcurrentHashMap and AtomicInteger, Java Memory Model and the volatile keyword, Java 8 streams and Optional, and design patterns. Senior roles add questions on microservices, Spring Boot internals, and performance profiling with tools like JProfiler or VisualVM.
Last updated: June 2025. Reviewed by the 3University editorial team.