Tcs Iinterview Questions
Tcs Iinterview Questions
Tcs Iinterview Questions
A linked list consists of two parts: information and the link. In the single connected listening, the
beginning of the list is marked by a unique pointer named start. This pointer does point to the first
element of the list and the link part of each node consists of an arrow looking to the next node, but
the last node of the list has null pointer identifying the previous node. With the help of start pointer,
the linked list can be traversed easily.
The four basic principles of Object-Oriented Programming System are listed below:
o Abstraction: Abstraction is a process of hiding the implementation details and showing only
functionality to the user. For example, sending SMS where you type the text and send the
message. You don't know the internal processing about the message delivery.
o Abstraction lets you focus on what the object does instead of how it does it.
o Inheritance: Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object.
o Encapsulation: Encapsulation in Java is a process of wrapping code and data together into a
single unit, for example, a capsule which is mixed of several medicines.
o Polymorphism: Polymorphism in Java is a concept by which we can perform a single action
in different ways. Polymorphism is derived from 2 Greek words: poly and morphs. The word
"poly" means many and "morphs" means forms. So polymorphism means many forms.
3) What is inheritance?
Inheritance refers to inhering the data members and properties of a parent class to a child class. A
class which is derived from another level is often called as a sub-class or a child class, and the type
from which the child class is obtained is known as super-class or parent class.
4) What is the way of inheriting variable of one class to any other class?
1. //Base Class
2. class A
3. {
4. public int a;
5. }
6. //Derived Class
7. class B : A
8. {
9. a=15;
10. }
5) What is Polymorphism?
Polymorphism is a concept in OOPS which means having many forms. In simple words, it means
that different actions will be performed in different instances. Polymorphism is of two types:
1. Method overloading
2. Operator overloading
Types of Inheritance:
1. Single inheritance
2. Multiple Inheritance
3. Multi-level Inheritance
4. Multi-path Inheritance
5. Hierarchical Inheritance
6. Hybrid Inheritance
o A class can be instantiated by creating its object, whereas interfaces cannot be instantiated as
all the methods in the interface are abstract and do not perform any action, so there is no
use of instantiating an interface.
o A class is declared using class keyword whereas an interface is declared using interface
keyword.
o The members of the class can have access specifier such as public, protected, and private but
members of the interface can not have the access specifier, all the members of the interface
is declared as public because the interface is used to derive another class. There will be no
use to access specifies inside the members of an interface.
o The methods inside the class are defined to perform some actions on the fields declared in
the class whereas interface lacks in asserting in areas, the ways in an interface are purely
abstract.
o A class can implement any number of the interface but can only extend one superclass.
Whereas interface can reach any number of interfaces but cannot perform any interface.
o A class can have a constructor defined inside the class to declare the fields inside the class,
whereas interface doesn't have any constructor defined because there are no fields to be
initialized.
Software development life-cycle is steps involved in the life cycle of software development phase.
Generally, it is followed by the development team which develops the software in the organization.
It consists of a clear explanation of developing and maintaining the software.
Normalization is process of organizing data in a database efficiently. Two goals of the normalization
process are: to eliminate redundant data (for example, storing the same data in more than one
table) and also ensure data dependencies make sense (only storing related data in a table). These
both are important as they reduce the amount of space a database consumes and ensure that data
is logically stored.
Loops are used to execute block of statement several times in a program depending upon the
conditional statement. The basic structure of a circuit is given above in the diagram. For each
successful execution of the loop, the conditional statement should be checked. If the conditional
statement is true, then the circuit will be executed. If the conditional statement is false, then the
course will be terminated.
The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a
relationship between specific columns in these tables.
A view is a virtual table. A look contains rows and columns, just like a real table. The fields in a
picture are fields from one or more real tables in the database.
You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the
data were coming from one single table.
A DataBase Management System is a software system used for creating and managing databases.
DBMS make it possible for the end user to build and maintain databases. DBMS provides an
interface between the end user/application and the databases.
The formal definition of the database schema is a set of formulas (sentences) called integrity
constraints imposed on a database.
16) What is the difference between the foreign key and reference key?
Reference Key is the primary key that is referenced in the other table (linked via the other tables
Foreign Key). Foreign Key is how you connect the second table to the primary tables Primary Key (or
Reference Key).
C does not support function overloading. In C, for input or output, we use functions like gets(),
puts(), scanf(), printf(), etc
Btree
It is made of branch nodes and leaf nodes. Branch nodes hold prefix key value along with the link to
the leaf node and the leaf nodes contain the indexed value and rowed.
Bitmap
It consists merely of bits for every single distinct value. It uses a string of bits to locate rows in a
table quickly. It is used to index low cardinality columns.
19) What is the difference between a Clustered index and non-clustered index?
Clustered Index
Non-Clustered Index
int a[10];
This defines an array whose name is a and has ten elements from index 0-9
22) Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array.
Optimize the boundary conditions.
1. #include<stdio.h>
2. #include<conio.h>
3. void main()
4. {
5. int A[10]={'0','1','0','1','0','0','0','1','0','1','0','0'};
6. int x=0,y=A.length-1;
7. while(x
8. x++;
9. else if(A[y])
10. y--;
11. if(A[x] && !A[y])//here we are checking that stating index is having 1 and last index having 0
than swap values
12. A[x]=0,A[y]=1;
13. }
14. getch();
15. }
Abstraction is the basis for software development. It's through this concept we define the essential
aspects of a system. The process of identifying and designing the ideas for a given system is called
Modeling ( objectmodeling).
24) Write a function to swap two numbers without using a temporary variable.
1. void swap(int &i, int &j)
2. {
3. i=i+j;
4. j=i-j;
5. i=i-j;
6. }
The calloc() function allocates a memory area; the length will be the product of its parameters (it has
two settings). calloc fills the memory with ZERO's and returns a pointer to the first byte. If that fails
to locate enough space, it returns a NULL pointer.
A malloc() function allocates a memory area; length will be the value entered as parameter. (it has
one parameter). It does not initialize memory area
The free() function is used to free the allocated memory(allocated through the calloc and malloc), in
other words, this used release the allocated memory
new also used to allocate memory on the heap and initialize the memory using constructor
1. int i=10;
2. printf("%d%d%d",i,++i,i++);
Answer= 10 12 12
Virtual function:- To achieve polymorphism, function in base class is declared as virtual. By state
virtual, we make a base class pointer to execute the purpose of any derived class depends on the
content of pointer (any acquired class address).
Pure Virtual Function:- This is the function used in base class, and its definition has to be provided
in derived class, In other pure virtual function has no definition in the base is declared as :
1. virtual void fun()=0;
It means that this function is not going to do anything, In case of pure virtual function derived
function has to
WPF/WCF application, need in .NET 3.0 Framework. These application will cover the following
concepts:
o Styles
o Templates
o Animations
o Databinding
29) Write a program in C to swap two numbers without help of a third variable.
1. /*
2. * C++ program to swap two numbers without using a temporary variable
3. */
4. #include<iostream>
5. using namespace std;
6.
7. /* Function for swapping the values */
8. void swap(int &a, int &b)
9. {
10. b = a + b;
11. a = b - a;
12. b = b - a;
13. }
14. int main()
15. {
16. int a, b;
17.
18. cout << "Enter two numbers to be swapped : ";
19. cin >> a >> b;
20. swap(a, b);
21. cout << "The two numbers after swapping become :" << endl;
22. cout << "Value of a : " << a << endl;
23. cout << "Value of b : " << b << endl;
24. }
1. // file name: Main.java
2.
3. class Complex {
4. private double re, im;
5.
6. public Complex(double re, double it) {
7. this.re = re;
8. this.im = im;
9. }
10. }
11.
12. // Driver class to test the Complex level
13. public class Main {
14. public static void main(String[] args) {
15. Complex c1 = new Complex(10, 15);
16. System.out.println(c1);
17. }
18. }
1. public class Prg {
2. public static void main(String args[]){
3. System.out.print("A" + "B" + 'A');
4. }
5. }
1. public class Prg {
2. public static void main(String args[]){
3. System.out.print('A' + 'B');
4. }
5. }
1. public class Prg {
2. public static void main(String[] args) {
3. char [] str={'i','n','c','l','u','d','e','h','e','l','p'};
4. System.out.println(str.toString());
5. }
1. public class pg {
2. public static void main(String[] args) {
3. System.out.print("Hello");
4. System.out.println("Guys!");
5. }
1. class Test2 {
2. ublic
3. static void main(String[] args)
4. {
5. byte x = 12;
6. byte y = 13;
7. byte result = x + y;
8. System.out.print(result);
9. }
1. #include <stdio.h>
2. union test {
3. int x;
4. char arr[8];
5. int y;
6. } u;
7. int main()
8. {
9. printf("%u", sizeof(u));
10. return 0;
11. }
12.
My name is Abhinav. I belong to Delhi. I was born in my native place and brought up in Delhi. I am a
person who likes to explore new areas and meet new people. Coming to my academics, I have
passed my B.Tech from GNIOT, Greater Noida with 64%. I have secured 72% in Class XII and 8.2
CGPA in Class X. In my family, I have a father, mother, grandfather & grandmother and me. I had a
work experience of x months in Javatpoint at Noida as a content writer and had gained a lot of
knowledge about various languages.
I want to work in an organization where I can develop the skill set gained from my Educational
background as well as develop skills which will benefit throughout my career as regarding this job,
this job is entirely connected with my domain of expertise, and also it helps me to enhance my
communication skills which have been on my to-do list. So I want to get associated with such a big
organization and also improve skill sets that I have always been wanting to upgrade.
3) Describe an experience of yours wherein you were asked to do something which you didn't like to
do and how you handled it?
This is a typical question which tests your presence of mind and your communication skills. Gather
any instance from your life and speak on that.
For your reference, a sample answer is provided. Your answer will be different from this one, but it
might be of some help.
I have many life instances where I had to perform tasks which I did not like performing but as these
tasks were mandatory hence backing off was not an option I could afford. One such memory I
would like to share was from my 9th grade when we had to study Sanskrit as our school did not
have option between Hindi and Sanskrit after class 9th so initially I did not care about this subject
but when I started researching it I found that this subject is quite complicated and also I realized
that I was not all good at remembering things, hence this subject became a difficult task for me but
as I told backing off was not an option so I decided to take help from my parents, friends and other
reliable sources and worked hard throughout the remaining time and at last the hard work paid off
though I did not score excellent marks I achieved marks which I could not have believed I could
score a few months back.
Though this answer is objective and can be different for different persons but remember be positive
in your thoughts and do not say many things about the company which gives the interviewer an
illusion that you are exaggerating.
I have from a long time wanted to work with an IT company which treats its employees in the best
way it can. I have always wanted to work with an organization which provides a very comfortable
and home like work environment and when it comes to TCS I find that both the requirements are
fulfilled. Even requirements I can hardly imagine are met, most importantly I get the opportunity to
learn and enhance my skill set to become a better professional in the future.
Remember this answer requires a clear-cut reply and wants to know as the company might provide
time to time travel hence do not try to be good and if you are not able to change places tell them
explicitly if they have any positions for that kind of post they will consider you. Also, refer to the
sample answer given below.
Yes, as part of growing up I used to travel a lot as my father is an ex-serviceman hence occasionally
he used to be posted throughout the country. Though I would prefer my city as it helps me live with
people, I care about, but at the same time, I am ok with relocating.
You can tell unique things about your states; this may consist of things which you might or want to
improve, as a said before stick to being realistic.
Delhi is one of the busiest cities in India and though I do not have any knowledge of towns outside
India hope it will also be the most active of all. Delhi like Mumbai never sleeps and in Delhi, as we
know have lots of places to wander and explore. Also being central to many states and the Capital
of India it is the center of attraction for many, and hence due to constant migration, we find a
variety of people residing in Delhi. Also, Delhi has all kinds of markets, and also it has hospitals and
facilities which are top notch and can be compared to best across the globe. Hence, living in Delhi is
like a dream come true.
By this question, the interviewer wants to check whether you can cope with on-the-spot situations,
take some time gather your thoughts and speak up.
The most memorable day of my life would without any second thought be the day when I passed
my graduation. That day I felt like now I can get a respectable job lead an independent life and
slowly and steadily I have turned from a dependent boy to independent man. I am now mature
enough to take my life decisions and decide what is right for me and what is not. That day I realized
why my grandfathers and old people are so nostalgic and have so many memories associated with
the Independence of our country and such small word independence could have such massive
meaning attached to it.
Never tell strengths which you cannot prove on the spot. And speak only the forces that are true.
In my opinion, I am a team player I have always loved working as a team, performing for the
betterment of the team has ever made me proud and getting to handle captaincy or leadership of
my colleagues has always been the work I always loved.
Also, things that are hard to get I love getting them, though it sounds bit confusing to understand
so let me elaborate with an instance, After my graduation I had not acquired skills required to get
an excellent job through my communication skills were ok but I really lacked in technical part, and it
was easy for me to take nonprofessional job also they had an attractive pay scale and it was difficult
for me to learn programming skills and become good in coding but I decided to get things the hard
way and work till I succeed and thereafter I worked on technical domain and here I am .So hard
work eventually pays off.
Though this is a tricky question but doesn't be the bait, i.e., the interviewer wants to know your
weakness but tell him weakness such that they are also in some way your strengths.
Though it is difficult to see your weakness yourself as we all know the general human tendency is to
shift the blame and never take the responsibility for some wrongdoing. But to be honest, I find that
when I want to achieve something, I work hard to get that though it might not be worth it to work
so hard for the happiness that I get after attaining I work hard, so in the meantime I miss out on
another event concurrently happening.
10) Why should we hire you?
The requirement for this job completely matches my skill set, as a candidate I have experience
working in this domain which might be beneficial for the organization as well as me. Also, I am a
quick learner and a team player so the organization won`t have to spend much time and resources
on me. Even when I work, I work for the maximum benefit of the organization. Moreover, I would
gain exposure to the industry which will be very beneficial to my career.
11) Is there anything which makes you different from other candidates?
Again...Be realistic
Yes, there are lots of things which distinguish me as an individual. Every individual is different. But if
you ask about positive qualities in me, then I would say I am a team player, quick learner and have
some leadership qualities. Though these thoughts are objective to individual and can be known
better when you know me as an individual.
This is a significant topic of discussion, and I have a lot of things to say, but considering the short
duration of this interview I would like to summarize this like:
o It was a very significant decision I would say, but not that great on the implementation part.
o The government should have taken a stand on so many people died during the initial period.
o The objective was not met entirely as not many people having black money were caught.
o The GDP of our country had increased.
o All in all, there are many positives and negatives in this action hence to reach a conclusion
would not do justice.
Nowadays, I have quite a hectic schedule, and I have long been reaching out for a holiday or break,
but as you ask I would describe my routine as:
I wake up at 0700hours. I perform all my daily chores and get ready to leave for office at about 0800
hours. I commute by metro, and then I reach my office at an estimated time of 0930 hours. I work
there till 1300 hours and then we have a half an hour break, after the break, we get back to work,
and I have a Java class from 1530 to 1700, and after completing the course, I work for about 90
minutes, and at 1830 hours I depart for home. Again my house is 90 minutes ride in metro, and by
2000 hours I reach home and watch a great movie and by the time the film is finished I am off to
sleep and the day is finished and next day again back to work.
14) Mention any five qualities that a person should have for this profile?
Depends on the job.
16) Describe the experience of visiting any place during your vacations.
17) Do you have any prior work experience? If so tell us about your last job and why you left it.
You can tell about your work experience, and why left it but don't give any negative answer as they
have a negative impact. Answer like for growth, for a better opportunity, to enhance your skill set
further.
You can tell your hobbies. You must prepare for questions from your hobbies.
There are many qualities that a leader should have but to name a few, a leader should be able to
coordinate a team, he should have excellent understanding of people and their behavior at different
points of time, he should be able to find people he can depend on, he should be able to be
distinguished in a crowd of people, he should be able to instruct a group of people, he should be
dominant and many more are there.
20) Have you applied anywhere before applying here? How many job offers have you received
before this?
what is your strongest programming language (Java, ASP, C, C++, VB, HTML, C#, etc.)?
Point to remember: Before interview You should decide your Favorite programming language and be prepared based
on that question.
10.What is a class?
Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After creation the user
need not know the specifics of the working of a class.
Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have
different sets of parameters (at least as far as their types are concerned). This capability is called function overloading.
When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and
order of the arguments in the call. Function overloading is commonly used to create several functions of the same name
that perform similar tasks but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes.
Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add
anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
It permits code reusability. Reusability saves time in program development. It encourages the reuse of proven and
debugged high-quality software, thus reducing problem after a system becomes functional.
26. Tell something about deadlock and how can we prevent dead lock?
In an operating system, a deadlock is a situation which occurs when a process enters a waiting state because a resource
requested by it is being held by another waiting process, which in turn is waiting for another resource. If a process is
unable to change its state indefinitely because the resources requested by it are being used by other waiting process,
then the system is said to be in a deadlock.
Mutual Exclusion: At least one resource must be non-shareable.[1] Only one process can use the resource at any given
instant of time.
Hold and Wait or Resource Holding: A process is currently holding at least one resource and requesting additional
resources which are being held by other processes.
No Preemption: The operating system must not de-allocate resources once they have been allocated; they must be
released by the holding process voluntarily.
Circular Wait: A process must be waiting for a resource which is being held by another process, which in turn is waiting
for the first process to release the resource. In general, there is a set of waiting processes, P = {P1, P2, ..., PN}, such that
P1 is waiting for a resource held by P2, P2 is waiting for a resource held by P3 and so on till PN is waiting for a resource
held by P1.[1][7]
Thus prevention of deadlock is possible by ensuring that at least one of the four conditions cannot hold.
27. What is Insertion sort, selection sort, bubble sort( basic differences among the functionality of the three sorts and not
the exact algorithms)
A doctor sees (abstracts) the person as patient. The doctor is interested in name, height, weight, age, blood group,
previous or existing diseases etc of a person
An employer sees (abstracts) a person as Employee. The employer is interested in name, age, health, degree of study,
work experience etc of a person.
Abstraction is the basis for software development. Its through abstraction we define the essential aspects of a system.
The process of identifying the abstractions for a given system is called as Modeling (or object modeling).
Three levels of data abstraction are:
1. Physical level : how the data is stored physically and where it is stored in database.
2. Logical level : what information or data is stored in the database. eg: Database administrator
3.View level : end users work on view level. if any amendment is made it can be saved by other name.
33.Which header file should you include if you are to develop a function which can accept variable number of arguments?
stdarg.h
35.What is debugger?
A debugger or debugging tool is a computer program that is used to test and debug other programs
36. Const char *p , char const *p What is the difference between the above two?
1) const char *p - Pointer to a Constant char ('p' isn't modifiable but the pointer is)
2) char const *p - Also pointer to a constant Char
However if you had something like:
char * const p - This declares 'p' to be a constant pointer to an char. (Char p is modifiable but the pointer isn't)
38.Explain the difference between 'operator new' and the 'new' operator?
The difference between the two is that operator new just allocates raw memory, nothing else. The new
operator starts by using operator new to allocate memory, but then it invokes the constructor for the right
type of object, so the result is a real live object created in that memory. If that object contains any other
objects (either embedded or as base classes) those constructors as invoked as well.
42. Why should we use data ware housing and how can you extract data for analysis with example?
If you want to get information on all the techniques of designing, maintaining, building and retrieving data, Data
warehousing is the ideal method. A data warehouse is premeditated and generated for supporting the decision making
process within an organization.
Here are some of the benefits of a data warehouse:
o With data warehousing, you can provide a common data model for different interest areas regardless of data's source.
In this way, it becomes easier to report and analyze information.
o Many inconsistencies are identified and resolved before loading of information in data warehousing. This makes the
reporting and analyzing process simpler.
o The best part of data warehousing is that the information is under the control of users, so that in case the system gets
purged over time, information can be easily and safely stored for longer time period.
o Because of being different from operational systems, a data warehouse helps in retrieving data without slowing down
the operational system.
o Data warehousing enhances the value of operational business applications and customer relationship management
systems.
o Data warehousing also leads to proper functioning of support system applications like trend reports, exception reports
and the actual performance analyzing reports.
Data mining is a powerful new technology to extract data for analysis.
43.Explain recursive function & what is the data structures used to perform recursion?
a) A recursive function is a function which calls itself.
b) The speed of a recursive program is slower because of stack overheads. (This attribute is evident if you run above C
program.)
c) A recursive function must have recursive conditions, terminating conditions, and recursive expressions.
Stack data structure . Because of its LIFO (Last In First Out) property it remembers its caller so knows whom to return
when the function has to return. Recursion makes use of system stack for storing the return addresses of the function
calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative
procedures are written, explicit stack is to be used.
46.What is an interrupt?
Interrupt is an asynchronous signal informing a program that an event has occurred. When a program receives an
interrupt signal, it takes a specified action.
47.What is user defined exception in Java?
The keywords used in java application are try, catch and finally are used in implementing used-defined exceptions. This
Exception class inherits all the method from Throwable class.
Garbage collection is the systematic recovery of pooled computer storage that is being used by a program when that
program no longer needs the storage. This frees the storage for use by other programs
(or processes within a program). It also ensures that a program using increasing amounts of pooled storage does not
reach its quota (in which case it may no longer be able to function).
Garbage collection is an automatic memory management feature in many modern programming languages, such as Java
and languages in the .NET framework. Languages that use garbage collection are often interpreted or run within a virtual
machine like the JVM. In each case, the environment that runs the code is also responsible for garbage collection.
if(item == arr[middle])
{
return(middle);
}
return(-1);
}
53.What is Cryptography?
Cryptography is the science of enabling secure communications between a sender and one or more
recipients. This is achieved by the sender scrambling a message (with a computer program and a secret
key) and leaving the recipient to unscramble the message (with the same computer program and a key,
which may or may not be the same as the sender's key).
There are two types of cryptography: Secret/Symmetric Key Cryptography and Public Key Cryptography
54.What is encryption?
Encryption is the transformation of information from readable form into some unreadable form.
55.What is decryption?
Decryption is the reverse of encryption; it's the transformation of encrypted data back into some intelligible form.
56.What exactly is a digital signature?
Just as a handwritten signature is affixed to a printed letter for verification that the letter originated from its purported
sender, digital signature performs the same task for an electronic message. A digital signature is an encrypted version of
a message digest, attached together with a message.