TCS interview questions

2,783 questions from 501 interviews · updated from reports 2014-2025

Practise TCS-style

About

TCS, or Tata Consultancy Services, is an Indian IT services and consulting company that builds and supports software, cloud, and data systems for clients. In India, it hires entry-level candidates for Software Engineer roles and campus tracks such as TCS Ninja and TCS Digital.

The roles that come up most are Software Engineer, TCS Digital and TCS Ninja. This covers 501 candidate interviews reported from 2014 to 2025. Most sat it at entry level (491 of 496 that recorded a level), with 5 internship interviews alongside. Among the 392 that recorded either route, arrivals split between campus drives (163, 42%) and off-campus applications (229, 58%). Most questions fall under CS fundamentals and DSA.

Category
Difficulty
Round

Interview questions

Q. What are the differences between C and Java?

asked 13xeasyOOPHR, Technical2017-2023

Ans. C is a procedural, compiled, low-level language with manual memory management, while Java is object-oriented, runs on a virtual machine, and uses garbage collection. C gives more control over memory and hardware, so it is common in systems programming. Java favours portability, safety, and large application development through its standard runtime.

Q. Explain different types of SQL joins.

asked 11xeasySQLTechnical2019-2025

Ans. SQL joins combine rows from related tables using a matching condition, usually a key. INNER JOIN returns only matching rows. LEFT JOIN returns all rows from the left table plus matches from the right. RIGHT JOIN is the reverse. FULL OUTER JOIN returns all rows from both sides. CROSS JOIN returns every combination of rows.

Q. What is the difference between C++ and Java?

asked 10xeasyOOPTechnical2017-2024

Ans. C++ is a compiled systems language with manual memory control, while Java is a managed language that runs on the JVM with automatic garbage collection. The most important difference is control versus portability: C++ gives closer access to hardware and performance tuning, while Java offers safer memory handling and easier cross-platform execution.

Q. Write a program to generate the Fibonacci series.

asked 10xeasyArraysTechnical2017-2024

Ans. Generate the Fibonacci series by starting with 0 and 1, then repeatedly adding the previous two numbers to get the next term until the required count is reached. Store the values in an array or list if they must be returned. The time complexity is O(n), with O(n) space, or O(1) if printed directly.

Q. Write a program to check whether a number is prime.

asked 9xeasyMathOnline test, Technical2017-2024

Ans. A number is prime if it is greater than 1 and has no divisors other than 1 and itself. Handle n less than or equal to 1 as not prime, then test divisibility only up to the square root of n. This uses constant space and runs in O(sqrt n) time.

Q. What are ACID properties in DBMS?

asked 8xeasyDBMSTechnical2020-2025

Ans. ACID properties are the guarantees that make database transactions reliable: Atomicity, Consistency, Isolation and Durability. Atomicity means all or nothing, Consistency keeps valid rules, Isolation prevents concurrent transactions interfering, and Durability ensures committed changes survive crashes. They are essential for correctness in systems handling critical data.

Q. What is the difference between C and C++?

asked 8xeasyOOPTechnical2019-2024

Ans. C is mainly a procedural systems programming language, while C++ extends C with object oriented and generic programming features. The key practical difference is that C++ provides classes, constructors, destructors, templates and a richer standard library, enabling abstractions such as RAII and containers while still supporting low level memory control.

Q. Check whether a given string or number is a palindrome

asked 7xeasyStringsOnline test, Technical2017-2024

Ans. Use two pointers, one at the start and one at the end, and compare characters while moving inward. For a number, either convert it to a string or reverse its digits and compare with the original. The string approach uses constant extra data and runs in O(n) time.

Q. What is the difference between an abstract class and an interface in Java?

asked 7xeasyOOPTechnical2019-2024

Ans. An abstract class is a partial base class, while an interface is mainly a contract a class agrees to implement. An abstract class can hold instance state, constructors, and concrete methods, but a class can extend only one. A class can implement multiple interfaces, which is useful for defining shared capabilities.

Q. What is the difference between DBMS and RDBMS?

asked 6xeasyDBMSHR, Technical2020-2024

Ans. A DBMS stores and manages data, while an RDBMS is a type of DBMS that stores data in related tables. The key difference is that an RDBMS enforces relationships using keys, such as primary and foreign keys, and usually supports SQL, constraints, normalisation, and stronger data integrity rules.

Q. Swap two numbers without using a third variable.

asked 6xeasyBasic mathTechnical2016-2024

Ans. Swap them using arithmetic: set the first number to the sum of both, set the second to the new first minus the second, then set the first to the new first minus the new second. This uses constant space and constant time. The key caveat is integer overflow, so a temporary variable is usually safer.

Q. Explain the software development life cycle (SDLC).

asked 6xeasySoftware engineeringManagerial, Technical2017-2024

Ans. SDLC is a structured process for planning, building, testing, deploying, and maintaining software. It gives teams a clear path from requirements to release, reducing risk and improving quality. Common stages include requirement analysis, design, implementation, testing, deployment, and maintenance, often repeated in agile or iterative models.

Q. What are the four pillars of Object-Oriented Programming?

asked 6xeasyOOPTechnical2018-2024

Ans. The four pillars of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation hides internal state behind methods. Abstraction exposes only essential behaviour. Inheritance lets classes reuse and extend other classes. Polymorphism lets different objects be treated through the same interface while providing their own behaviour.

Q. What is the difference between a list and a tuple in Python?

asked 6xeasyOOPTechnical2021-2024

Ans. A list is mutable, while a tuple is immutable. Lists can have items added, removed, or changed after creation, but tuples cannot. Lists use square brackets and tuples use parentheses. Tuples are often used for fixed collections of values and can be hashable if all their elements are hashable.

Q. What is Object-Oriented Programming (OOP)?

asked 5xeasyOOPTechnical2017-2020

Ans. Object-Oriented Programming is a programming style that organises software around objects, which combine data and behaviour. Objects are usually created from classes. The key idea is encapsulation: keeping state and the operations on that state together, with controlled access. OOP also commonly uses abstraction, inheritance and polymorphism.

Q. What is the difference between HTTP and HTTPS?

asked 5xeasyNetworkingTechnical2019-2021

Ans. HTTP sends data between a browser and a server in plain text, while HTTPS uses TLS to encrypt that data. The important difference is security: HTTPS protects confidentiality, helps verify the server’s identity using certificates, and prevents tampering in transit. HTTP commonly uses port 80, and HTTPS uses port 443.

Q. What is the difference between a stack and a queue?

asked 5xeasyData structuresTechnical2019-2024

Ans. A stack removes the most recently added item first, while a queue removes the earliest added item first. This is usually called LIFO for stack and FIFO for queue. Stacks are used for function calls, undo, or parsing. Queues are used for scheduling, buffering, and breadth first search.

Q. Check whether a given number is an Armstrong number.

asked 5xeasyMathOnline test, Technical2017-2024

Ans. To check whether a number is an Armstrong number, count its digits, sum each digit raised to that count, and compare the sum with the original number. For example, 153 is valid because 1³ + 5³ + 3³ = 153. Process digits using division and modulo. Time complexity is O(d), space is O(1).

Q. What is the difference between DELETE and TRUNCATE in SQL?

asked 5xeasySQLTechnical2019-2022

Ans. DELETE removes selected rows and can use a WHERE clause, while TRUNCATE removes all rows from a table. DELETE is usually row logged, can fire delete triggers, and is slower for large tables. TRUNCATE deallocates data pages, is faster, often resets identity values, and cannot be used when referenced by foreign keys.

Q. What is the difference between range and xrange in Python?

asked 5xeasyPythonTechnical2019-2022

Ans. In Python 2, range creates a full list in memory, while xrange returns a lazy sequence object that generates values as needed. The key practical difference is memory use, especially for large ranges. In Python 3, range behaves like Python 2’s xrange, and xrange no longer exists.

Q. Explain the difference between method overloading and method overriding in Java

asked 5xeasyOOPTechnical2019-2024

Ans. Method overloading means defining multiple methods with the same name but different parameter lists in the same class, while method overriding means a subclass provides a new implementation of a superclass method with the same signature. Overloading is resolved at compile time, but overriding uses dynamic dispatch at runtime.

Q. Solve the 0/1 Knapsack problem using dynamic programming.

asked 4xmediumDynamic programmingOnline test, Technical2019-2024

Ans. Use dynamic programming where dp[i][w] stores the maximum value using the first i items with capacity w. For each item, either skip it or take it if its weight fits, choosing the better value. The table size is n by capacity, so time is O(nW) and space is O(nW), reducible to O(W).

Q. What is a friend function in C++?

asked 4xeasyOOPTechnical2019-2020

Ans. A friend function in C++ is a non-member function that is allowed to access the private and protected members of a class. It is declared inside the class using the friend keyword, but it is defined and called like a normal function. It is commonly used for operator overloading or related helper functions.

Q. What is the final keyword in Java?

asked 4xeasyOOPTechnical2017-2024

Ans. The final keyword in Java prevents further change to a variable, method, or class in a specific way. A final variable cannot be reassigned, a final method cannot be overridden, and a final class cannot be extended. For object references, final fixes the reference, not the object’s internal state.

Q. What is a lambda function in Python?

asked 4xeasyOOPTechnical2020-2021

Ans. A lambda function in Python is a small anonymous function defined with the lambda keyword. It can take any number of arguments but contains only one expression, whose value is returned automatically. It is commonly used for short callbacks, such as sorting with a key function, where defining a full function would be unnecessary.

Q. Write an SQL query to create a table.

asked 4xeasySQLTechnical2017-2024

Ans. Use a CREATE TABLE statement with the table name followed by each column name, data type, and any constraints. For example, define an id column as an integer primary key, then add columns such as name, email, and created_at with suitable types. The key detail is choosing correct data types and constraints.

Q. Explain Stack and Queue data structures.

asked 4xeasyData structuresTechnical2019-2024

Ans. A stack and a queue are linear data structures that store items in a specific order for removal. A stack is last in, first out, like undo history, with push and pop operations. A queue is first in, first out, like a waiting line, with enqueue and dequeue operations. Both commonly run in constant time.

Q. What are the differences between C and C++?

asked 4xeasyOOPTechnical2020

Ans. C is a procedural language, while C++ is largely a superset of C with object oriented and generic programming features. C++ adds classes, inheritance, polymorphism, templates, exceptions, references, function overloading and the standard library. The most important difference is abstraction: C gives low level control, while C++ supports higher level design without losing that control.

Q. What is call by value and call by reference?

asked 4xeasyFunctionsTechnical2020-2024

Ans. Call by value passes a copy of the argument to a function, while call by reference passes access to the original variable. With call by value, changes inside the function do not affect the caller’s variable. With call by reference, changes can affect the original object or variable.

Q. What is method overloading and method overriding?

asked 4xeasyOOPTechnical2019-2022

Ans. Method overloading means defining multiple methods with the same name but different parameter lists in the same class. Method overriding means a subclass provides its own implementation of a method already defined in its superclass. Overloading is resolved at compile time, while overriding uses runtime polymorphism.

Q. Swap two numbers without using a temporary variable

asked 4xeasyArraysTechnical2019-2025

Ans. Swap them by using arithmetic: store the sum in the first variable, derive the original first value into the second, then derive the original second value back into the first. This uses no extra data structure and runs in constant time. The key caveat is overflow, so a temporary variable is usually safer in real code.

Q. Explain encapsulation in object-oriented programming.

asked 4xeasyOOPTechnical2020-2023

Ans. Encapsulation is the practice of keeping an object’s data and the methods that operate on it together, while hiding internal details from outside code. The key point is controlled access: fields are usually private, and other code interacts through public methods, which helps protect invariants and reduce unintended dependencies.

Q. Explain the OSI model and the function of each layer.

asked 4xeasyNetworkingTechnical2015-2024

Ans. The OSI model is a seven-layer framework for network communication: physical sends bits, data link frames local traffic, network routes packets, transport provides end-to-end delivery, session manages connections, presentation formats and encrypts data, and application supports user-facing protocols. The key idea is separation of responsibilities, making networks easier to design, debug, and standardise.

Q. Write a program to check whether a number is a palindrome.

asked 4xeasyNumbersOnline test, Technical2017-2021

Ans. A number is a palindrome if it reads the same forwards and backwards. Handle negatives as not palindromes, then reverse the digits numerically, or reverse only half to avoid overflow, and compare with the original or remaining half. No data structure is needed. Time complexity is O(d), space complexity is O(1), where d is digit count.

Q. What is the difference between an abstract class and an interface?

asked 4xeasyOOPTechnical2019-2024

Ans. An abstract class is a base class that can share state and implemented behaviour, while an interface defines a contract that classes agree to implement. The key detail is inheritance: a class usually extends one abstract class, but can implement multiple interfaces, making interfaces better for capabilities across unrelated classes.

Q. What is the difference between method overloading and method overriding?

asked 4xeasyOOPTechnical2019-2020

Ans. Method overloading means defining multiple methods with the same name but different parameter lists in the same class, while method overriding means a subclass provides its own implementation of a method already defined in its parent class. Overloading is resolved at compile time, whereas overriding is resolved at runtime using dynamic dispatch.

Q. Implement Quick Sort algorithm.

asked 3xmediumSortingTechnical2014-2024

Ans. Quick Sort is a divide and conquer sorting algorithm that chooses a pivot, partitions the array so smaller elements go before it and larger elements after it, then recursively sorts both sides. Its key detail is pivot choice: average time is O(n log n), but poor pivots can make it O(n²).

Q. How does memory allocation work in Python?

asked 3xmediumOperating systemsTechnical2021

Ans. Python allocates memory dynamically on a private heap managed by the Python memory manager. Every value is an object, and variables hold references to objects, not raw values. CPython mainly frees objects using reference counting, with a cyclic garbage collector for reference cycles. Small objects are handled by specialised allocators for speed.

Q. Verbal ability questions testing English comprehension and grammar

asked 3xmediumVerbalOnline test2020-2024

Ans. Read the question carefully and identify what is being tested: meaning, grammar, vocabulary, tone, or sentence structure. For comprehension, find evidence in the passage rather than relying on opinion. For grammar, check subject verb agreement, tense, articles, prepositions, modifiers, and punctuation. Eliminate clearly wrong options, then compare the remaining choices closely.

Q. Write an SQL query to find the second highest salary from a table.

asked 3xmediumSQLTechnical2019-2021

Ans. Select the distinct salaries, sort them in descending order, skip the first row, and return the next one. This gives the second highest unique salary. The key detail is using distinct, otherwise duplicate top salaries can give the wrong result. The database typically uses sorting, so the time cost is about O(n log n).

Q. What are storage classes in C?

asked 3xeasyOOPTechnical2020-2021

Ans. Storage classes in C++ define an object’s lifetime, visibility, and linkage. The main specifiers are static, extern, thread_local, and mutable. Historically, auto and register were also storage class specifiers, but auto now means type deduction and register is obsolete. The key idea is how long data exists and where it can be accessed.

Q. Explain Internet of Things (IoT)

asked 3xeasyEmerging technologiesHR, Technical2016-2019

Ans. The Internet of Things is a network of physical devices that contain sensors, software and connectivity so they can collect, send and sometimes act on data. The key idea is that everyday objects, such as thermostats, cars or factory machines, can communicate with systems or each other over the internet.

Q. How do you retrieve data in SQL?

asked 3xeasySQLTechnical2021

Ans. You retrieve data in SQL using a SELECT query. You specify the columns to return, the table to read from, and optional clauses to filter, join, group, sort, or limit the results. The most important detail is to fetch only the data you need, using conditions such as WHERE.

Q. Why is String immutable in Java?

asked 3xeasyOOPTechnical2019-2024

Ans. String is immutable in Java so its value cannot change after creation, which makes it safe to share. This matters because strings are widely used for class names, file paths, network connections and keys in maps. Immutability also enables string pool reuse, thread safety without locking, and reliable cached hash codes.

Q. Explain the Bubble Sort algorithm.

asked 3xeasySortingTechnical2020-2024

Ans. Bubble sort repeatedly scans the array, compares adjacent elements, and swaps them if they are in the wrong order. After each full pass, the largest unsorted element moves to its final position. Stop after no swaps occur, or after n minus 1 passes. It sorts in place, with O(n²) time and O(1) space.

Q. What is the static keyword in Java?

asked 3xeasyOOPTechnical2019-2024

Ans. The static keyword in Java makes a member belong to the class rather than to an object instance. A static variable is shared by all instances, and a static method can be called using the class name. Static methods cannot directly access instance fields or methods because they are not tied to a specific object.

Q. Explain the layers of the OSI model.

asked 3xeasyNetworkingTechnical2019-2024

Ans. The OSI model has seven layers: physical, data link, network, transport, session, presentation and application. They describe how data moves from raw bits on a medium, through framing, routing and reliable delivery, up to user-facing protocols. The key idea is separation of concerns, so each layer provides services to the one above.

Q. Explain ACID properties in databases.

asked 3xeasyDBMSTechnical2018-2024

Ans. ACID properties are guarantees that make database transactions reliable: Atomicity, Consistency, Isolation, and Durability. Atomicity means all changes commit or none do. Consistency keeps data valid under rules and constraints. Isolation makes concurrent transactions behave safely. Durability means committed changes survive crashes, usually through logging and persistent storage.

Q. Explain the Java Collection Framework.

asked 3xeasyCollectionsTechnical2019-2024

Ans. The Java Collection Framework is a standard set of interfaces and classes for storing, accessing and manipulating groups of objects. Its core interfaces include List, Set, Queue and Map, with implementations such as ArrayList, HashSet, PriorityQueue and HashMap. The main benefit is consistent APIs, reusable algorithms and predictable performance choices.

Q. Probability-based quantitative aptitude problems

asked 2xmediumProbabilityOnline test2019

Ans. Identify the total number of equally likely outcomes and the number of favourable outcomes, then use probability equals favourable outcomes divided by total outcomes. For combined events, decide whether to add, multiply, or subtract overlap. Use complements for “at least one” cases, and conditional probability when information changes the sample space.

Q. How to integrate a payment gateway into an application?

asked 2xmediumWeb architectureTechnical2019

Ans. Integrate a payment gateway by using its server-side API or SDK to create payment intents, redirect or collect tokenised details, then confirm payment and update orders from verified webhooks. The most important detail is to treat the gateway webhook as the source of truth, with signature verification, idempotency keys, retries, and no raw card storage.

Q. How would you handle a teammate who is not performing up to expectations?

asked 2xmediumConflict resolutionManagerial2020

Ans. A strong answer should use a real example where you addressed the issue early and respectfully. Emphasise understanding the cause, offering support, clarifying expectations, and protecting team outcomes. Interviewers listen for empathy, accountability, clear communication, and knowing when to involve a manager if performance does not improve.

Q. How would you impress your coach to become the captain of a basketball team?

asked 2xmediumLeadershipManagerial2020

Ans. Pick a real example where you led through effort, discipline, and team-first behaviour, not just scoring. Emphasise reliability in training, communication, helping weaker players, staying calm under pressure, and respecting decisions. Interviewers listen for maturity, humility, consistency, accountability, and evidence that others trusted you before you sought the title.

Q. Numerical ability questions covering arithmetic and basic quantitative aptitude

asked 2xmediumNumerical abilityOnline test2023-2024

Ans. Break the problem into what is given, what is asked, and which formula or operation connects them. Convert units first, then use arithmetic carefully, keeping track of percentages, ratios, averages, speed, time, work, or profit as needed. Estimate before calculating to spot errors, and check whether the final answer is reasonable.

Q. How does a team's performance differ if the captain is calm versus short-tempered?

asked 2xmediumLeadershipManagerial2020

Ans. A strong answer should compare impact on team confidence, decision-making, and communication. Pick a real team situation where leadership style affected results. Emphasise that calm captains create trust, focus, and accountability, while short-tempered captains can cause fear and mistakes. Interviewers listen for maturity, fairness, and understanding of leadership under pressure.

Q. How do you optimize a REST API?

asked 1xmediumApi designTechnical2024

Ans. Optimise a REST API by measuring bottlenecks first, then reducing work per request and avoiding repeated work. The biggest gains usually come from efficient database queries, proper indexes, pagination, caching with correct HTTP headers, smaller payloads, compression, and connection pooling. Track latency, throughput, error rate, and cache hit rate.

Q. Design an E-Commerce application

asked 1xmediumApplication designTechnical2019

Ans. Design it as modular services for catalogue, search, cart, checkout, payment, orders, inventory, users and notifications, behind an API gateway and web or mobile clients. Use a relational database for orders and payments, a search index for products, cache hot catalogue data, and make checkout event driven so inventory, payment and fulfilment stay consistent.

Q. Given a square, divide it into 7 equal parts.

asked 1xmediumLogical reasoningManagerial2019

Ans. Mark one side of the square into seven equal lengths. From each mark, draw a straight line parallel to the opposite side across the square. This creates seven congruent rectangles. Each rectangle has the same width and the full height of the square, so each has one seventh of the square’s area.

Q. Multiply two 3-digit numbers mentally without using pen or paper.

asked 1xmediumLogical reasoningTechnical2017

Ans. There is no single numerical answer without the two numbers. A good mental method is to split them around an easy base. For example, 987 × 996 = (1000 − 13)(1000 − 4). That is 1,000,000 − 13,000 − 4,000 + 52 = 983,052. Use rounding, then adjust for the differences.

Q. Using a 3L and a 5L mug, how can you measure exactly 4L of water?

asked 1xmediumLogical reasoningTechnical2019

Ans. Fill the 5L mug, then pour into the 3L mug until it is full, leaving 2L in the 5L mug. Empty the 3L mug. Pour the 2L into the 3L mug. Fill the 5L mug again, then pour into the 3L mug until full. Exactly 4L remains in the 5L mug.

Showing 60 of 2,783 questions. Ranked by how often the same question came back across interviews.

Practise a TCS-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does TCS ask?

Candidate interviews most often cover CS fundamentals (69%) and DSA (19%).

How many rounds does TCS interview have?

Candidate interviews show an average of 2.8 rounds per experience, with a typical sequence of Online test → Technical → HR. Individual interview paths can vary.

Is the TCS interview hard?

Among questions with a recorded difficulty, the mix is easy 67%, medium 32%, hard 1%.