TCS
100+ TCS Interview Questions and Answers
Q101. What is a Constructor
A constructor is a special type of method in a class that is automatically called when an object of that class is created.
Constructors have the same name as the class they belong to
They are used to initialize the object's state
They can have parameters to customize the initialization process
Q102. Write a Plindrome Code
A palindrome code reads the same forwards and backwards.
Create a function that compares the original string with its reverse
Use built-in functions like reverse() or loop through the string to create the reversed version
Handle cases where spaces or punctuation may be present in the string
Q103. 2) how to reverse a string
To reverse a string, iterate through it in reverse order and append each character to a new string.
Create an empty string to store the reversed string
Iterate through the original string in reverse order using a loop
Append each character to the new string using the += operator
Return the reversed string
Q104. Are you good at programming
Yes, I am proficient in programming with experience in multiple languages and projects.
Proficient in multiple programming languages such as Python, Java, and C++
Experience working on various projects including web development, data analysis, and software engineering
Strong problem-solving skills and ability to write efficient and clean code
Q105. Where did you learnt coding
I learned coding through online courses, coding bootcamps, and self-study.
Took online courses on platforms like Coursera, Udemy, and Codecademy
Attended a coding bootcamp to gain hands-on experience and mentorship
Self-studied using resources like books, tutorials, and coding challenges
Q106. Can you explain oops concepts
OOPs concepts refer to Object-Oriented Programming principles like Inheritance, Encapsulation, Polymorphism, and Abstraction.
Inheritance: Allows a class to inherit properties and behavior from another class. Example: Parent class 'Animal' and child class 'Dog'.
Encapsulation: Bundling data and methods that operate on the data into a single unit. Example: Class 'Car' with private variables and public methods.
Polymorphism: Ability to present the same interface for different data...read more
Q107. What are joins in SQL.
Joins in SQL are used to combine rows from two or more tables based on a related column between them.
Joins are used to retrieve data from multiple tables based on a related column
Common types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column
Q108. DDL and DML difference
DDL is used to create, modify or delete database objects while DML is used to manipulate data within those objects.
DDL stands for Data Definition Language and includes commands like CREATE, ALTER, DROP, etc.
DML stands for Data Manipulation Language and includes commands like SELECT, INSERT, UPDATE, DELETE, etc.
DDL commands are used to create, modify or delete database objects like tables, indexes, etc.
DML commands are used to manipulate data within those objects like insertin...read more
Q109. What is Deep Learning
Deep learning is a subset of machine learning that uses neural networks to learn from large amounts of data.
Deep learning is a type of machine learning that uses neural networks with multiple layers to learn patterns from data
It is particularly effective for tasks such as image and speech recognition, natural language processing, and autonomous driving
Examples of deep learning frameworks include TensorFlow, PyTorch, and Keras
Q110. What is oops. Explain.
Oops stands for Object-Oriented Programming. It is a programming paradigm that uses objects to represent and manipulate data.
Oops is a programming paradigm
It focuses on using objects to represent data and perform operations
It promotes code reusability, modularity, and flexibility
Examples of object-oriented programming languages include Java, C++, and Python
Q111. explain different types of JOIN in dbms
Different types of JOIN in DBMS include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
INNER JOIN: Returns rows when there is at least one match in both tables.
LEFT JOIN: Returns all rows from the left table and the matched rows from the right table.
RIGHT JOIN: Returns all rows from the right table and the matched rows from the left table.
FULL JOIN: Returns rows when there is a match in one of the tables.
Q112. 1. Write a program to find prime number
A program to find prime numbers in a given range or up to a certain number.
Iterate through numbers from 2 to n, checking if each number is divisible by any number from 2 to its square root.
Use a boolean array to mark non-prime numbers and return the list of prime numbers.
Optimize by only checking odd numbers after 2, as all other even numbers are not prime.
Q113. PRINT REPEATING ELEMNTS IN AN ARRAY
Print repeating elements in an array of strings
Iterate through the array and use a hashmap to store the frequency of each element
Print elements with frequency greater than 1
Q114. Check if a number is a palindrome
A palindrome number is the same when read forwards and backwards.
Convert the number to a string to easily check for palindrome
Reverse the string and compare it with the original string to check for palindrome
If the reversed string is equal to the original string, then the number is a palindrome
Q115. OOPS in JAVA, explain in details
OOPS in JAVA refers to Object-Oriented Programming concepts like classes, objects, inheritance, polymorphism, and encapsulation.
OOPS stands for Object-Oriented Programming
Key concepts include classes, objects, inheritance, polymorphism, and encapsulation
Java is an object-oriented programming language that follows OOPS principles
Example: Creating a class 'Car' with properties like 'make', 'model', and methods like 'drive', 'stop'
Q116. Difference between tuple and list
Tuple is immutable and ordered while list is mutable and ordered.
Tuple uses () while list uses []
Tuple is faster than list for accessing elements
Tuple can be used as keys in dictionaries while list cannot
Tuple is used for heterogeneous data while list is used for homogeneous data
Q117. Oops concepts (explain with example)
Oops concepts are fundamental principles of object-oriented programming that help in organizing and designing code.
Encapsulation: Bundling data and methods that operate on the data into a single unit (class). Example: Class Car with properties like make, model, and methods like start(), stop().
Inheritance: Allows a class to inherit properties and behavior from another class. Example: Class Truck inheriting from class Vehicle.
Polymorphism: Ability of objects to take on multipl...read more
Q118. reverse a string
Reverse a given string
Use a loop to iterate through the characters of the string
Append each character to a new string in reverse order
Return the reversed string
Q119. tell about http vs ip
HTTP is a protocol used for transferring data over the internet, while IP is a unique address assigned to devices on a network.
HTTP stands for Hypertext Transfer Protocol and is used for transmitting web pages, images, videos, etc. between a web server and a client's browser.
IP stands for Internet Protocol and is a numerical label assigned to each device connected to a network to identify and locate them.
HTTP operates at the application layer of the OSI model, while IP operat...read more
Q120. string regex ques to sanitise string
Use regular expressions to sanitize strings by removing unwanted characters or patterns.
Use regex patterns to match and replace unwanted characters or patterns in the string.
For example, to remove all non-alphanumeric characters from a string: str.replace(/[^a-zA-Z0-9]/g, '')
Be careful with regex patterns to ensure that only the intended characters are removed.
Q121. what is oops in c++?
Oops in C++ stands for Object-Oriented Programming System. It is a programming paradigm that uses objects and classes for data organization and manipulation.
Oops in C++ allows for encapsulation, inheritance, and polymorphism.
Classes in C++ are used to create objects, which can have attributes (data members) and behaviors (member functions).
Example: class Car { private: int speed; public: void accelerate() { speed += 10; } };
Example: Car myCar; myCar.accelerate();
Q122. State full or stateless difference
Stateful vs stateless refers to whether or not the server retains information about the client between requests.
Stateful: Server retains client information between requests
Stateless: Server does not retain client information between requests
Stateful example: HTTP cookies
Stateless example: RESTful APIs
Q123. Write code check for palindrome
Code to check if a given array of strings are palindromes
Iterate through each string in the array
Reverse the string and compare it with the original string to check for palindrome
Return true if it is a palindrome, false otherwise
Q124. What are keys in sql
Keys in SQL are used to uniquely identify rows in a table and establish relationships between tables.
Keys ensure data integrity by enforcing uniqueness and relationships between tables
Primary key uniquely identifies each row in a table
Foreign key establishes a relationship between two tables
Q125. What is Gen AI
Gen AI refers to the next generation of artificial intelligence that is capable of learning, adapting, and evolving on its own.
Gen AI utilizes advanced machine learning algorithms to continuously improve its performance
It can analyze vast amounts of data to make predictions and decisions
Gen AI has the potential to revolutionize industries such as healthcare, finance, and transportation
Q126. inheritance and polymorphism difference
Inheritance is a way to create a new class from an existing class while polymorphism is the ability of an object to take on many forms.
Inheritance allows a subclass to inherit properties and methods from a superclass.
Polymorphism allows objects of different classes to be treated as if they are of the same class.
Inheritance is a way to achieve code reusability while polymorphism allows for flexibility in code design.
Example of inheritance: class Dog extends Animal
Example of po...read more
Q127. what is overriding
Overriding is a concept in object-oriented programming where a subclass provides a specific implementation of a method that is already provided by its superclass.
Occurs in inheritance when a subclass provides a specific implementation of a method that is already provided by its superclass
The method in the subclass must have the same name, return type, and parameters as the method in the superclass
Allows for polymorphism, where a subclass can be treated as an instance of its s...read more
Q128. What is constructor
A constructor is a special type of method in a class that is automatically called when an object of that class is created.
Constructors have the same name as the class they belong to
They can be used to initialize object properties
They do not have a return type
Example: public class Car { public Car() { // constructor code here }}
Q129. Java and polymorphism in it
Java supports polymorphism, allowing objects of different classes to be treated as objects of a common superclass.
Polymorphism is achieved through method overriding and method overloading.
Polymorphism allows for code reusability and flexibility.
Example: Animal class with subclasses like Dog and Cat, where they can be treated as objects of the Animal class.
Q130. Explain the concept on OOP
OOP is a programming paradigm based on the concept of objects, which can contain data in the form of fields and code in the form of procedures.
OOP focuses on creating objects that interact with each other to solve problems.
Objects have attributes (data) and methods (functions) that define their behavior.
Encapsulation, inheritance, and polymorphism are key principles of OOP.
Example: In a car simulation program, a 'Car' object could have attributes like 'color' and 'speed', and...read more
Q131. Osi layer in serial order
The OSI layer in serial order refers to the Open Systems Interconnection model which is a conceptual framework used to understand network communication.
Physical Layer
Data Link Layer
Network Layer
Transport Layer
Session Layer
Presentation Layer
Application Layer
Q132. Abstraction vs interface
Abstraction focuses on hiding implementation details, while interfaces define a contract for classes to implement.
Abstraction allows for defining common behavior without specifying implementation details
Interfaces define a set of methods that a class must implement, providing a contract for how the class should behave
Abstraction can be achieved through abstract classes in languages like Java
Interfaces are used to achieve multiple inheritance in languages like C#
Q133. reverse string in c++
To reverse a string in C++, you can use the reverse function from the algorithm library.
Include the algorithm header file: #include
Use the reverse function with begin() and end() iterators
Example: string str = 'hello'; reverse(str.begin(), str.end());
Q134. Find duplicate in list
Find duplicates in a list of strings
Iterate through the array and store each element in a hash set
If an element is already in the hash set, it is a duplicate
Q135. write programs
Yes, I can write programs in various programming languages.
Proficient in languages like Python, Java, C++, etc.
Experience with data structures and algorithms
Able to develop web applications, mobile apps, and more
Q136. reverse a string
A function that reverses a given string and returns it.
Create an empty string to store the reversed string
Iterate through the input string from the end to the beginning and append each character to the new string
Return the reversed string
Q137. reverse array in c++
To reverse an array of strings in C++, use the std::reverse function.
Include the
header to use the std::reverse function. Call std::reverse with the beginning and ending iterators of the array.
Example: std::reverse(arr.begin(), arr.end());
Q138. Projects during ug
I worked on various projects during my undergraduate studies.
Developed a mobile app for a class project
Participated in a research study on environmental sustainability
Collaborated with classmates on a group presentation for a business course
Q139. Favourite language
My favorite language is Python.
Python is a versatile and powerful programming language.
It has a simple and readable syntax, making it easy to learn and use.
Python has a vast ecosystem of libraries and frameworks for various purposes.
It is widely used in fields like web development, data analysis, and artificial intelligence.
Python's popularity and community support make it a great choice for developers.
More about working at TCS
Top HR Questions asked in TCS
Interview Process at TCS
Reviews
Interviews
Salaries
Users/Month