Quick Answer: Java Interview Questions for Freshers 2026
The top 40 Java interview questions asked at TCS, Infosys, Accenture, Cognizant, and Capgemini in 2026 cover seven clusters: core Java fundamentals (data types, control flow, arrays, strings), OOP (classes, inheritance, polymorphism, abstract class vs interface), Collections framework (List/Set/Map, ArrayList vs LinkedList, HashMap internals, ConcurrentHashMap), exception handling (try/catch/finally, checked vs unchecked, try-with-resources), multithreading (Thread vs Runnable, synchronized, volatile, Executor framework), Java 8 features (lambda, Streams, Optional, method references), and Spring/Spring Boot basics (IoC, dependency injection, REST, JPA). Most fresher interviews include 10-15 Java MCQs plus 2-3 coding problems (string reversal, palindrome, factorial, fibonacci, array operations). For the full Q&A collection with 25 curated questions at all difficulty levels, see the TutorsBot Java Interview Questions hub.
The 7 Topic Clusters Asked Most Often
Cluster 1: Core Java Fundamentals
The mandatory baseline. Questions: What are the primitive data types (byte, short, int, long, float, double, char, boolean) and their sizes? What is the difference between == and .equals() (== compares references for objects; .equals() compares content, defaulting to reference equality unless overridden)? What is the difference between String, StringBuilder, and StringBuffer (String is immutable; StringBuilder is mutable and not thread-safe; StringBuffer is mutable and thread-safe but slower)? What is autoboxing and unboxing (automatic conversion between primitive and wrapper class)? What is the difference between int and Integer (primitive vs reference type; Integer can be null, int cannot; Integer has methods)? How does Java handle strings (String pool, interning)? What is method overloading vs overriding? TCS NQT and Wipro NLTH ask 5-8 questions from this cluster alone.
Cluster 2: Object-Oriented Programming
The deepest cluster for service-company Java interviews. Questions on the four pillars: encapsulation (data hiding via private fields + public getters/setters), inheritance (extends, IS-A relationship, method overriding, covariant return types), polymorphism (compile-time overloading vs runtime overriding, dynamic dispatch, virtual method invocation), and abstraction (abstract classes vs interfaces, when to use which). Other classics: What is the diamond problem and how does Java resolve it (multiple inheritance of state via default methods in interfaces is allowed, but if a class inherits two default methods with the same signature, the compiler requires you to override explicitly)? What is the difference between an abstract class and an interface (concrete methods, state, constructors vs pure contract)? What are access modifiers (private, default, protected, public)? What is composition vs inheritance (HAS-A vs IS-A)? Infosys InfyTQ and Accenture AASS include 3-5 OOP questions plus a live coding question asking you to design a class hierarchy.
Cluster 3: Collections Framework
The second heaviest cluster. Questions on the core interfaces (Collection, List, Set, Map, Queue, Deque), implementations (ArrayList, LinkedList, HashSet, TreeSet, LinkedHashSet, HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap), and when to use each. The classics: ArrayList vs LinkedList (array vs linked list, O(1) random access vs O(1) middle insertion), HashSet vs TreeSet (hash table vs red-black tree, O(1) vs O(log n) operations, ordered vs unordered iteration), HashMap vs TreeMap vs LinkedHashMap (hash-based vs tree-based vs insertion-order, O(1) vs O(log n), insertion-order iteration), HashMap vs Hashtable (HashMap is not thread-safe and allows nulls; Hashtable is thread-safe and does not - though Hashtable is legacy code; use ConcurrentHashMap for new code). How does HashMap work internally (buckets, hash collision, red-black tree conversion for buckets with 8+ entries since Java 8) is a near-universal fresher question. Cognizant GenC Next and Capgemini ask 4-6 collection questions plus a HashMap iteration problem.
Cluster 4: Exception Handling
Tested at every level. Questions: What is the difference between checked and unchecked exceptions (checked must be caught or declared with throws, unchecked extend RuntimeException and do not require handling)? What is the difference between throw and throws (throw is used to throw an exception, throws declares exceptions a method can throw)? What is the difference between final, finally, and finalize (final is a modifier for classes/methods/variables meaning cannot be changed, finally is a block that always runs after try/catch for cleanup, finalize is an obsolete Object method that ran before garbage collection but is deprecated since Java 9)? What is try-with-resources (Java 7 feature that auto-closes resources implementing AutoCloseable, like Connection, Statement, BufferedReader)? What are the common exceptions (NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException, NumberFormatException, IllegalArgumentException, IOException, SQLException)? What is the exception hierarchy (Throwable → Exception / Error → RuntimeException for unchecked)?
Cluster 5: Multithreading
Heavy at Infosys Power Programmer, Cognizant GenC Next, and Capgemini. Questions: What is the difference between extending Thread and implementing Runnable (single inheritance limitation for Thread vs multiple interfaces for Runnable; prefer Runnable for sharing the same code among multiple threads; prefer Callable for returning a value)? What is the synchronized keyword and how does it work (intrinsic lock / monitor on the object; method-level vs block-level; reentrant)? What is volatile (ensures visibility of writes across threads; does NOT guarantee atomicity)? What is the wait/notify mechanism (on Object, must be called within synchronized block, releases the lock during wait)? What is the Executor framework (Java 5+ thread pool abstraction: Executor, ExecutorService, ScheduledExecutorService, ThreadPoolExecutor - separates task submission from execution mechanics)? What is the difference between HashMap and ConcurrentHashMap (HashMap is not thread-safe; ConcurrentHashMap uses bucket-level locking for high concurrency)? What is deadlock and how do you prevent it (circular wait, lock ordering, lock timeout, java.util.concurrent.locks.Lock with tryLock)? TCS Digital adds harder concurrency questions (Java memory model, happens-before, immutable objects for sharing).
Cluster 6: Java 8 Features
Still tested heavily even though Java 8 is 12 years old because most production code is still Java 8/11/17. The five must-know features: lambda expressions, Streams API, functional interfaces (java.util.function: Function, Predicate, Consumer, Supplier), Optional, method references. Practical questions: Write a stream pipeline that filters, maps, and collects (List of Strings from a List of Person, finding adults with names starting with A). What is the difference between map and flatMap (map transforms each element 1-to-1, flatMap transforms each element to a stream and concatenates the streams)? What is a functional interface (interface with exactly one abstract method, eligible for lambda expression, annotated with @FunctionalInterface)? When would you use Optional (return type for methods that may legitimately return no value; never as a field or parameter)? Accenture AASS and Cognizant GenC Next test Java 8 features heavily.
Cluster 7: Spring and Spring Boot Basics
Required for backend roles at all major companies in 2026. Questions: What is Spring (application framework providing dependency injection, AOP, data access, transaction management, MVC, security)? What is dependency injection (objects receive their dependencies from an external source rather than creating them - constructor injection, setter injection, field injection; constructor injection is preferred)? What is the Spring Bean lifecycle (instantiation, population of properties, BeanNameAware, BeanFactoryAware, ApplicationContextAware, BeanPostProcessor pre-initialization, InitializingBean afterPropertiesSet, custom init-method, BeanPostProcessor post-initialization, bean ready, DisposableBean destroy, custom destroy-method)? What is Spring Boot (opinionated Spring with auto-configuration, embedded servers like Tomcat, starter dependencies for common combinations)? What is @SpringBootApplication (combination of @Configuration, @EnableAutoConfiguration, @ComponentScan)? What is a REST controller (@RestController = @Controller + @ResponseBody; maps HTTP requests to handler methods via @GetMapping, @PostMapping, etc.)? What is JPA (Java Persistence API - ORM specification; Hibernate is the popular implementation; @Entity, @Id, @GeneratedValue, @OneToMany, @ManyToOne annotations)?
Top 10 Java Coding Questions Asked in 2026
These are the live coding problems that came up most often in 2026 fresher Java interviews at TCS/Infosys/Accenture/Cognizant/Capgemini:
- Reverse a string without using StringBuilder reverse
- Check if a string is a palindrome (ignoring case and non-alphanumeric)
- Find the factorial of a number (iterative and recursive)
- Generate the Fibonacci sequence up to n terms
- Find duplicate elements in an array
- Find the second largest element in an array
- Implement a singly linked list with add, remove, and display operations
- Sort an array using bubble sort, selection sort, and merge sort (write the algorithm and explain complexity)
- Implement FizzBuzz from 1 to 100
- Check if two strings are anagrams of each other
For the full 40-question list with code, expected time/space complexity, and the company that asks each one, see the TutorsBot Java Interview Questions hub.
Common Fresher Pitfalls to Avoid
- == vs .equals(): == compares references for objects (and only works correctly for primitives); always use .equals() for content comparison (the String, Integer, and other wrapper classes override equals)
- Mutable vs immutable objects: Strings are immutable - every operation returns a new string; modifying a String variable just points it to a new object
- HashMap key requirements: keys must implement hashCode and equals consistently - two equal keys must have the same hashCode, and the key should be immutable (or hashCode/equals must be based on immutable state) to avoid breaking the HashMap when the key is modified
- ArrayList vs array: ArrayList supports generics and dynamic resizing; arrays have fixed size but slightly faster for primitive access
- Exception handling in finally: finally blocks run even when try returns or throws; do not use finally for cleanup that depends on the exception type - use catch for that
- Thread safety: HashMap, ArrayList, StringBuilder are NOT thread-safe; HashTable, Vector, StringBuffer are thread-safe but legacy; use ConcurrentHashMap, CopyOnWriteArrayList, StringBuilder + external synchronization for new code
- Pass by value (always): Java passes everything by value - object references are passed by value (the reference is copied), so reassigning the parameter does not affect the caller but mutating the object does
- String concatenation in loops: Building strings with + in a loop is O(n^2) - use StringBuilder.append instead
How to Prepare in 30 Days
The strongest 30-day fresher Java interview preparation plan:
- Week 1 - Core Java: Work through the Oracle Java Tutorials (docs.oracle.com/javase/tutorial), complete HackerRank Java domain (Easy track), practice 30 basic MCQs
- Week 2 - OOP and Collections: Practice 30+ collection questions (especially HashMap internals), write a small project using OOP (a library system, a bank account system, an e-commerce cart)
- Week 3 - Multithreading and Java 8: Practice 20+ multithreading scenarios, learn lambda/Streams/Optional thoroughly, complete 30 stream pipeline exercises
- Week 4 - Spring and mock tests: Build a simple Spring Boot REST API (CRUD for a TODO list with JPA), take 2-3 timed mock tests (TCS NQT pattern, Infosys InfyTQ pattern), review the Java Interview Questions hub for the full Q&A collection
For a structured, project-based path from Java fundamentals to backend developer roles, the TutorsBot DevOps and Cloud Engineering training covers Java, Spring Boot, microservices, and cloud deployment end-to-end.
Frequently Asked Questions
How many Java questions are asked in TCS NQT 2026?
TCS NQT 2026 typically includes 10-15 Java questions in the coding/technical section for Digital and Prime profiles, plus 1-2 advanced coding problems. For Ninja profiles, the count is lower (5-10 MCQs, 1 coding problem). TCS Digital adds Spring Boot and microservices questions for the Java track.
Is Java enough to get placed in TCS/Wipro/Infosys?
Java alone is rarely enough - companies test a combination of Java, DSA, SQL, and aptitude/reasoning. The strongest fresher profile combines: Java proficiency (intermediate to advanced including collections, multithreading, Java 8), DSA (50-100 problems on LeetCode Easy/Medium, with special focus on strings, arrays, linked lists, trees, sorting), SQL (intermediate joins, window functions), communication skills, and 2-3 small projects on GitHub. Infosys Power Programmer and Cognizant GenC Next require stronger DSA than TCS NQT.
What is the salary for Java freshers at these companies in 2026?
Salary bands for freshers with Java skills in 2026: TCS Ninja ₹3.36 LPA, TCS Digital ₹7-8 LPA, TCS Prime ₹9-11 LPA. Wipro ₹3.5-5 LPA. Infosys (InfyTQ Power Programmer) ₹6.5-9.5 LPA, regular InfyTQ ₹3.6 LPA. Cognizant GenC ₹4.5-6 LPA, GenC Next ₹7-12 LPA. Accenture AASE ₹4.5-6 LPA, AASS ₹6-9 LPA. Capgemini ₹4-6 LPA. HCL ₹3.5-5.5 LPA. Product companies (Flipkart, Razorpay, PhonePe) pay 2-3x these bands for strong Java + Spring Boot + DSA candidates.
Is Java enough for product company interviews at Flipkart, Razorpay, PhonePe?
Yes, but with much stronger DSA and Spring Boot requirements. Product companies test Java fluency plus deep DSA (arrays, strings, hash maps, trees, graphs, dynamic programming, recursion, BFS/DFS), system design basics (caching, databases, API design, microservices, message queues), and behavioral interviews. Practice 100-150 LeetCode Medium problems, build 2-3 production-grade Spring Boot projects with clean code on GitHub, and prepare system design. The interview loop is typically 4-6 rounds spanning coding, system design, and behavioral.
What is the best resource for Java interview preparation?
The strongest resources are: the official Oracle Java tutorials (docs.oracle.com/javase/tutorial - covers everything precisely), Baeldung tutorials (baeldung.com - in-depth articles on specific Java topics), GeeksforGeeks Java section (geeksforgeeks.org/java - interview-focused content), HackerRank Java domain (hands-on coding practice), Effective Java by Joshua Bloch (the classic Java best-practices book - intermediate to advanced), and the TutorsBot Java Interview Questions hub for curated 25 questions at all difficulty levels. Combine the official documentation for correctness, Baeldung/GeeksforGeeks for interview patterns, HackerRank/LeetCode for coding practice, and a curated interview question set for company-specific patterns.
Resources and Next Steps
The authoritative sources listed (Oracle Java SE documentation, Baeldung, GeeksforGeeks, HackerRank, Java Language Specification) are the canonical references for Java fundamentals and interview preparation. For the full 25-question curated Q&A collection at all difficulty levels (Level 1 foundational, Level 2 intermediate, Level 3 advanced), see the TutorsBot Java Interview Questions hub. For related interview prep, see our Python interview questions, OOPs interview questions, and DBMS interview questions guides.






