Interview Questions

TCS Ninja Interview Questions 2024

Preparing for the TCS Ninja (NQT) interview, a standardized assessment conducted by Tata Consultancy Services (TCS), requires understanding potential questions that may be asked, practicing clear and concise communication, and demonstrating both technical proficiency and soft skills.

Scroll down to practice the latest TCS Ninja Interview Questions.

Note: The TCS Ninja is not a separate exam; it is conducted as part of the TCS National Qualifier Test (NQT). To qualify for the TCS Ninja job roles, candidates must first take and pass the TCS National Qualifier Test (NQT).

TCS Ninja Interview Process - Quick Overview

Here's an overview of the TCS Ninja interview process:

Interview

The interview stage aims to provide a holistic assessment of candidates. It evaluates not only their technical competence but also their interpersonal skills, adaptability, and problem-solving capabilities.

The interview session is a comprehensive process that can vary in duration, typically spanning from 25 to 40 minutes.

Three Interview Panels: During this interview stage, candidates will interact with three distinct interview panels:

1. Technical Expert Panel:

 

This panel consists of experts in the relevant technical domain. They assess a candidate's technical knowledge, problem-solving abilities, and understanding of key concepts related to their field.

2. HR Panel:

 

The HR panel focuses on assessing the candidate's soft skills, communication abilities, and cultural fit within TCS. They may ask questions about the candidate's background, experiences, and motivations.

3. Managerial Panel:

 

The managerial panel evaluates a candidate's managerial and leadership potential. They may pose situational and behavioral questions to gauge the candidate's ability to handle challenges, make decisions, and work effectively within a team.

TCS Ninja Interview Questions

Technical Round

Note : For TCS Ninja / Digital and Prime , the initial set of interview questions are more or less similar and basic ( from the experience of previously attended candidates). Based on digital or prime , the difficulty level of questions may go up. So it’s better to prepare all the previously asked questions that are given below.,

1.

1. Name the pillars of Object-Oriented Programming. Is C++ an Object-Oriented programming language? Is C++ a purely object-oriented programming language?

The 4 pillars of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism.

  1. Abstraction: Abstraction means hiding the details from the user. For instance, when we build any application, we only let the user interact with it using buttons. We never let the user know what happens behind the clicks of the buttons.

  2. Encapsulation: As the name suggests, this means encapsulating different kinds of data into a single entity. For instance, when we make a class, we encapsulate the data and member functions into that single class.

  3. Inheritance: When a class inherits from another class, it shares the properties of the first class. For example, if we make a Student class, it inherits the class People as a student have all the properties of People like a student walks, talks, etc.. and apart from It, the Student has its own properties like enrollment number, subjects. etc.

  4. Polymorphism:: The word "poly" means many and the rod "morph" means form. This means that polymorphism means showing many forms. Polymorphism can be run-time or compile-time.

Examples of polymorphism are function overloading and function overriding.

Yes, C++ is an Object-Oriented programming language as we can create classes and objects and C++ can implement all the 4 pillars of OOPS. However, C++ is not a purely object-oriented

programming language. This is because a purely object-oriented programming language is such a language where all the functions are written inside a class and there are no primitive data types. Everything is an object in a pure object-oriented programming language.

2.

2. Write a program to swap two numbers. You cannot use a third variable and you cannot use the + (plus), - (minus), *(multiply), /(divide) operators.

The solution is using the XOR operator. Following is the c++ code for the same.

C++ Program

# include <algorithm>
# include <iostream>
# include <vector>
using namespace std
void swap (int &x. int &y) {
    x = x^y;
    y = x^y;
    x = x^y;
}
int main() {
    // Your code goes here;
    int x,y;
    cin >>x>>y;
    cout<<"Before swapping.x = "<< x <<" y = "<<y<<"";
    swap(x,y);
    cout<<"After swapping,x ="<<x<<" y = "<<y<<" ";
    return 0;
}

Sample Input:

10 20

Sample Output:

Before swapping,x = 10 y = 20

After swapping,x = 20 y = 10

3.

3. Write a program to perform Binary Search on an array.

The binary search algorithm is used to find an element in a sorted array. It is an optimized searching algorithm as the linear search scans all the elements of the array and the searching time for the linear search thus becomes O(N). However, the searching time of Binary Search is O(log2N). This is because in an average case, only log2N elements of an array are compared. We start by checking the middle element of the array. If the middle element of the array is our answer, we have found the element. If the number that we are searching for is greater than the middle element, it will be on the right half of the array as the array is sorted. So apply binary search on the right half. If the number that we are searching for is smaller than the middle element of the array, we will apply the binary search on the left half of the array. Following is the C++ program for binary search.

C++ Program for Binary Search

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int binarysearch(int arr[], int n, int target) {
    int lo = 0;
    int hi = n-1;
    while(lo <= hi) {
        int mid = lo + (hi-lo)/2;

        if(arr[mid] == target) return mid;
        else if(arr[mid] < target) lo = mid + 1;
        else hi = mid - 1;
    }
    return -1;
}
int main() {
    int arr[] = {10,12,25,36,42,58,97};
    if(binarysearch(arr, 7, 12) == -1) {
        cout << "Element was not found";
    } else {
        cout << "Element was found at index " << binarysearch(arr, 7, 12);
    }
}

Output:

Element was found at index 1

4.

4. Write a program to find whether a number is even or odd. You are not allowed to use any arithmetic operator i.e. plus (+), minus (-), multiply (*). divide(/), and modulus (%) are not allowed.

An even number in binary form will always have its Least Significant Bit (LSB) = 0. So, if we take the XOR of this number with 1. the answer will become one greater than the number itself. This is because 0 XOR 1 is 1 so. LSB will become 1 from 0 i.e, increment in the value by 1. So, we can say that if a number (N) is an even number then, if N^1= N + 1 else the number would be an odd number. So, the C++ program to solve the problem is given below.

C++ Program

# include <algorithm>
# include <iostream>
# include <vector>
using namespace std;
bool is_even(int N) {
    if((N^1) ==N + 1) return true;
    else return false;
}
int main() {
    //your code goes here;
    int N;
    cin>>N;
    if(is_even(N)) cout<<"The number is even";
    else cout<<"The number is odd";
}

Sample Input (Even Number):
10
Output:
The number is even
Sample Input (Odd Number);
9
Output:
The number is odd.

5.

5. List some linear and some non-linear data structures.

Linear Data structures: Arrays, Linked Lists, Stacks, Queues, and Dequeues, are all linear data structures.

Non-Linear Data structures: The non-linear data structures can further be categorized as circular and non-circular. Some circular data structures are Circular Queue. Circular Dequeue, Circular Linked List etc. Some non-circular data structures are Trees, Graphs, Priority queues, etc.

6.

6. List some major roles performed by an Operating System.

An operating system performs various roles. Some of the examples are as follows:

  1. Resource Governor: The OS acts as a resource governor so that there is no load on the system. It allocates and deallocates the resources to the processes and also handles the synchronization of these resources among various processes.

  2. Process Management: OS uses various Scheduling algorithms to manage the processes and their execution. This is done to increase the efficiency of the CPU so that it is never idle and the processes keep on executing.

  3. Storage Management: OS acts as a storage manager bus using its File System. The data of the user is stored in the foi-m of files and directories.

  4. Memory Management: Memory management and storage management are confused with each other. However, the storage management concerns the file system and storage of the data in the Computer, the memory management means managing the memory allocation to the processes at the time of execution, Which process should be kept in the Ready Queue, which is in the Waiting Queue (both these queues are inside RAM only).

  5. Privacy and Security: Privacy and security from any threats or viruses are also the responsibility of the OS. However, inter-process security is also the responsibility of the OS.

7.

7. Can we override the private methods?

No, we can't override the private methods. The private methods are those methods that have a scope only within the same class. Since they cannot be accessed outside the class even by a sub-class, there is no way to override the private methods.

8.

8. List some comparisons and similarities between the Java and C++ programming languages.

Java and C++ are both Object-Oriented Programming languages. However, everything in Java has to be inside a class, whereas this is not the case with C++. C++ has structures that are similar to classes but are used in Procedural Oriented Programming and not Object-Oriented Programming. Java does not have structures. Java has interfaces and C++ does not. Also, in C++ multiple inheritance is supported while it is not supported in Java.

C++ is fast as compared to Java because C++ is a compiled language, whereas Java is a hybrid language i.e. it is both compiled as well as interpreted. Also, Java uses JVM to run whereas C++ runs directly using the 05. Hence. Java is platform-independent whereas C++ is platform-dependent.

Java has Wrapper classes for each primitive data type. So, even though Java is not purely Object Oriented, it is possible to write a pure Object-Oriented Program in Java whereas it is not possible to do so in C++.

9.

9. What is DOM?

DOM stands for Document Object Model. It is an API (Application Programming Interface) that is used to access and change the contents of HTML elements. It provides a hierarchical structure of the web page that makes it easy to access the elements, their parents,their siblings and their children.

10.

10. Difference between Process and Thread.

Process Thread

System calls are involved in the ProcessOS treats different processes differently Different processes have different copies of data, files, codes. etc There is a Process Control Block (PCB) for each process. Hence, the overhead of the processes is more.Context switching is slow in the case of Processes.Blocking one process will not block another processProcesses are independent

There is no system call involved.All user-level threads are treated as a single task for the OS.Threads store the same copy of data. files and codes. Hence, overhead is low.It is fast in the case of threads. Blocking a thread blocks the entire process.Threads are interdependent.

11.

11. Difference between user-level thread and kernel-level thread.

User Level Thread Kernel Level Thread

These threads are managed by the User Library.They are typically fastContext switching is also fastThe entire process gets blocked on blocking one thread.

These threads are managed by the Operating System itself.The kernel-level threads are slower than the user-level threads.The Context Switching is slow as compared to the User level threads.If one Kernel thread is blocked, there is no effect on the others otherwise the whole can get erection.

12.

12. What is the relation between the pages and frames in the OS?

In OS, paging is the method of dividing each process into small segments called pages and the main memory is also divided into the frames so that each frame can accommodate one data page. Hence, the relation between pages and frames is

Size of page = Size of frame

13.

13. What is TCP/IP Protocol?

TCP stands for Transfer Control Protocol. The TCP is a connection-oriented protocol implemented at the Transport Layer of the OSI Model. TCP is responsible for breaking the data into the form of small frames called framing and later, at the receiver end, it also reassembles the frames back into the sequence to get the data back.

IP stands for Internet Protocol. It is present at the Network Layer of the OSI model. IP is not reliable and it is a connectionless model. IP is responsible for sending and receiving the data that is broken into the form of frames by the TCP. The IP is combined with TCP to form a reliable data sending-receiving Protocol.

14.

14. Write an SQL query to print the current date.

The SQL Query to print the current date is: GetDate{}

15.

15. Write an SQL Query to select all those entries from the table STUDENTS, whose name is Rahul.

The SQL Query to do so is

SELECT ‘FROM STUDENTS WHERE NAME = "Rahul"

16.

16. What do you know about DCL?

DCL means Data Control Language. DCL is responsible for managing the access and permissions to a DBMS. DCL helps in deciding which part of the Database should be accessed by which user. The 2 major commands in DCL are:

  1. GRANT: This command is used to grant privileges to the Objects of the database for a user. It helps one user to grant certain permissions to the other users.

  2. REVOKE: This command is used to withdraw the privileges for the objects of the database that have been granted to a user.

17.

17. Can constructors be overridden?

No, constructors are not overridden. The sub-class constructors have to call the super-class constructor for their creation as they inherit from the super-class. Hence, the constructors cannot be overridden.

18.

18. Do you know why the main() method is static in Java?

The main() method, like every other method in Java, is also inside a class. Now, when we compile or run the Java program, we do not create an object of the class containing the main() method. So. we have to make sure that the main() method can be accessed without creating an object of the main class. Hence, the main() method is static because the static methods belong to the class and not to a particular object.

19.

19. Write a program to print the right-angled triangle pattern as shown below for any value of N input by the user.

For N = z

*

**

***

****

*****

Let us observe the pattern carefully. We can see that in the 1st row, there is only 1 star and in the second row, there are 2 stars. and so on. This means that in the ith row, we are printing i number of stars. Following is the C++ program for the same.

C++ Program

# include <algorithm>
# include <iostream>
# include <vector>
using namespace std;
int main() {
   //your code goes here;
   int N;
   cin>>N;
   for(int i=1;i<=N;i++) {
       for(int j=1;j<=i;j++) {
           cout<<"*";
       }
       cout<<"\n";
   }
}

Sample Input : 7

20.

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

C++ is a compiled language, while Java is an interpreted language.

C++ supports pointers, while Java does not. C++ follows a procedural programming approach. while Java follows an object-oriented approach.

21.

21. Write a program to generate the Fibonacci series up to a given number.

def fibonacci(n):
    fib_series = [0,1]
    while fib_series[-1] + fib_series[-2] <= n:
        fib_series.append(fib_series[-1] + fib_series[-2])
        return fib_series
n = int(input("Enter the number: "))
print("Fibonacci series up to", n, ":", fibonacci(n))

22.

22. Write a program to reverse a string without using built-in functions or libraries.

def reverse_string(s):
    reversed_str =""
    for i in range(len(s) - 1, -1, -1):
        reversed_str += s[i]
        return reversed_str
    
input_str = input("Enter a string: ")
print(" Reversed string:", reverse_string(input_str))

23.

23. Write a program to calculate the factorial of a given number.

def factorial(n):i
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 1)
num = int(input("Enter a number: "))
print("Factorial of", num, "is", factorial(num))

24.

24. What is the purpose of the "static" keyword in Java?

The "static" keyword is used to declare variables, methods, and blocks that belong to classes rather than any specific instance. Static members can be accessed without creating an object of the class.

25.

25. Write a program to convert a binary number to its decimal equivalent.

def binary_to_decimal( binary):
    decimal = 0
    power = 0
    for digit in reversed(binary):
        decimal += int(digit)*(2** power)
        power += 1
        return decimal
binary_num = input("Enter a binary number:")
print("Decimal equivalent:", binary_to_decimal(binary_num))

26.

26. What is the difference between ArrayList and Linked List in Java?

Feature ArrayList LinkedList

Implementation

implements List interface

Implements List and Deque interfaces

Internal Structure

an array-like structure to store elements

a doubly-linked list structure

Random Access

Provides constant-time performance for random access of elements (O(1))

It will not provide constant- time performance for random access

27.

27. What is the difference between method overloading and method overriding in Java?

Feature Method Overloading Method Overriding

Definition

Allows a class to have multiple methods with the same name but different parameter lists

Allows a subclass to provide a specific implementation method —that is already defined in its parent class

Inheritance

Not dependent on inheritance

Dependent on inheritance

Access Modifier

Can have different access modifiers for overloaded methods

Must have the same or broader access modifier as the overridden method

28.

28. What is the purpose of the "final" keyword in Java?

The "final" keyword will restrict the modification of variables, methods, and

classes. A final variable cannot be reassigned, a final method cannot be overridden,

and a final class cannot be extended.

29.

29. Write a program to rotate elements of an array to the left by a given number of positions.

def rotate_array(arr, k):
    return arr[k:] + arr[:k]

array = [1,2,3,4,5]
k=2
print ("Original array:", array)
print("Array after rotation:", rotate array(array, k))

30.

30. What is the purpose of the "super" keyword in Java?

The "super" keyword is used to call the constructor or methods of the parent class from a subclass. It is also used to access the parent class members if they have been overridden in the subclass.

31.

31. What is the difference between the pre-increment (++i) and post-increment (i++) operators in Java?

The pre-increment operator (++i) increments the variable's value and then returns the incremented value, the post-increment operator (i++) returns the current value of the variable and then increments it.

32.

32. Write a program to sort elements of an array in ascending order using any sorting algorithm.

def bubble_sort(arr):
    n = len(arr)
    for i in range(n - 1):
        for j in range(0, n-i-1):
            if arr[j] > arr[j +1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
    
array = (64, 34, 23,12, 22,11,90)
print("Original array:", array)
bubble_sort( array)
print("Sorted array:", array)

33.

33. What is the difference between abstract and concrete classes in Java?

An abstract class is a class that cannot be instantiated and may contain abstract methods (methods without a body) that its subclasses must implement. A concrete class is a class that can be instantiated and contains implementation for all of its methods.

34.

34. What is the purpose of the "static" block in Java?

A "static" block in Java code, executed when the class is loaded into memory by the JVM. It will be to initialize static variables or perform another one-time initialization task.

35.

35. What is the difference between the "String" and "StringBuilder" classes in Java?

"String" class -Java is immutable, meaning its value cannot be changed once created. The "StringBuilder" class is mutable and provides a more efficient way to modify and manipulate strings.

36.

36. What is the purpose of the "instance of" operator in Java?

The "instance of" operator in Java is used to check whether an object is an instance of a particular class or an instance of a subclass of that class. It is commonly used for type-checking and casting objects.

37.

37. What is the purpose of the "package" in Java?

The "package" in Java to organize and group related classes and interfaces into a namespace. It helps to prevent naming conflicts and provides a way to control access to classes and interfaces.

38.

38. What is the difference between a "HashSet" and a "LinkedHashSet" in Java?

A "HashSet" is an unordered collection of unique elements, while a "LinkedHashSet" is an ordered collection of unique elements that maintains the insertion order of elements.

39.

39. What is the purpose of the "switch" statement in Java?

The "switch" statement in Java is a control flow statement that evaluates an expression and executes the associated block of code based on the value of the expression. It provides a more concise and readable alternative to nested "if-else" statements.

40.

40. What is the purpose of the "try-with-resources" statement in Java?

The "try-with-resources" statement in Java is used to automatically close resources (e.g., files, database connections, etc.) that implement the AutoCloseable interface. It ensures that these resources are properly closed, even in the event of an exception, eliminating the need for explicit closing in a "finally" block.

41.

41. What is the difference between "fail-fast" and "fail-safe" iterators in Java?

In Java, "fail-fast" iterators throw a ConcurrentModificationException if the collection is modified while iterating over it. This behavior is designed to prevent unexpected behaviors and maintain the integrity of the data.

On the other hand, "fail-safe" iterators create a copy of the collection and iterate over that copy, allowing modifications to the original collection without causing exceptions. However, the iterator may not reflect the changes made to the original collection. The Iterator interface in Java implements the "fail-fast" behavior, while the ConcurrentHashMap.KeySetView and ConcurrentHashMap.Values classes provide "fail-safe" iterators.

HR Round

The TCS Ninja interview Questions And Answers that will be asked in the HR round are the following:

1.

1. Who is the CEO of TCS?

Rajesh Gopinathan

2.

2. What is the difference between a service-based and a product-based company?

A product-based company focuses on selling physical goods to customers, while a service-based company offers intangible services to clients. Products are tangible and can be stored, whereas services are intangible and performed on demand.

3.

3. Have you ever experienced failure in your life? Tell me about that experience.

Yes, I have experienced failure in my life. One instance was when I put in a lot of hard work towards a project, but it did not yield the desired results. However, I learned from that experience, analyzed where I went wrong, and used those lessons to improve myself for future endeavors.

4.

4. Have you participated in any of TCS'competitions like Codevita?

I have participated in TCS'CodeVita competition, a coding challenge that tests programming skills and problem-solving abilities. It was a great learning experience that motivated me to improve my coding skills.

5.

5. Are you ready to relocate? Are you willing to sign the service agreement?

Yes, I am ready to relocate for this opportunity with TCS. I understand the requirement and am prepared to sign the service agreement.

6.

6. Tell me about yourself.

Candidates can tell their background, education, and key strengths relevant to the job role they applied.

7.

7. Why did you choose this career path?

Explain your interests, motivations, and factors affecting your decision to pursue this held.

8.

8. What are your strengths and weaknesses?

Highlight your strengths that align with the job requirements, and explain a weakness that is not a core competency for the role, along with how yj are working to improve it.

9.

9. Why do you want to work for TCS?

Research company culture, values, and growth opportunities at TCS (Tata Consultancy Services), and explain how they align with your career goals and Aspirations.

10.

10. How do you handle pressure or stress?

Provide examples of strategies you use to manage stress, such as time management, prioritization, or seeking support when needed.

11.

11. Describe a time when you faced a challenging situation and how you handled it.

Share a specific example that demonstrates your problem-solving abilities, resilience, and lessons learned.

12.

12. What motivates you?

Discuss factors that drive your performance, such as learning opportunities. challenging projects, or contributing to meaningful work.

13.

13. How do you handle conflicts or disagreements with team members?

Emphasize your ability to communicate effectively, listen to different perspectives, and find collaborative solutions.

14.

14. Describe a time when you had to work in a team.

Provide an example that showcases your teamwork skills, cooperation, communication, and contribution to a shared goal.

15.

15. What are your salary expectations?

Provide a range based on your research and be prepared to discuss your expectations while remaining flexible.

16.

16. How do you prioritize multiple tasks or projects?

Explain your approach to time management, setting priorities, and meeting deadlines effectively.

17.

17. What are your long-term career goals?

Share your aspirations and how this role at TCS aligns with your long-term career objectives.

18.

18. How do you handle criticism or feedback?

Emphasize your openness to constructive feedback and your commitment to continuous learning and improvement.

19.

19. What do you know about TCS's products or services?

Demonstrate your knowledge of TCS's offerings and how your skills and experience aligns with the company's business.

20.

20. Do you have any questions for us?

Prepare insightful questions about the role, company culture, or growth opportunities to demonstrate your interest in the position.

21.

21. How do you play to balance your work and personal life?

This cluestion assesses your ability to manage competing priorities and maintain a healthy work-life balance, which is crucial for productivity and well-being.

Frequently Asked QuestionsFAQ

What job roles are offered for TCS Ninja ?

TCS Ninja offers a variety of roles, including software developer, system engineer, test engineer, and business process services roles.

Is the TCS Ninja interview tough?

No, the difficulty of the TCS Ninja interview can vary based on the role and your preparation.

How many interview rounds are there in the TCS Ninja interview?

There are 3 (three) rounds in the TCS Ninja interview process, which include a technical round, a managerial round, and an HR round.

How long is the TCS Ninja interview?

Each TCS Ninja interview round usually lasts between 30 to 45 minutes, but the total length can vary depending on the interviewer and the specific role.

What types of technical questions are frequently asked in TCS Ninja interviews?

Technical questions often cover topics related to programming languages, data structures, algorithms, database management, networking, and sometimes domain-specific questions depending on the job role.

How should I prepare for my TCS Ninja interview?

Focus on strengthening your core technical skills for the TCS Ninja interview, practice common interview questions, understand the basics of software development and project management, and stay updated with the latest trends in technology.

What will be my salary if I pass the TCS Ninja interview?

The salary for TCS Ninja roles typically ranges around ₹3.36 lakhs per annum for undergraduates and ₹3.53 lakhs per annum for postgraduates.

Can I join TCS with one backlog?

No, TCS generally requires all academic backlogs to be cleared before joining. You can apply with 1 active backlog, but clear it before joining TCS.

When can I expect my TCS interview results?

TCS Ninja interview results can typically be expected within 1-3 weeks after the interview process is completed.

How many days does TCS take to give a joining letter?

The issuance of a TCS joining letter after clearing the interview can take anywhere from 1 to 3 months.