tata consultancy services

TCS Possible Technical interview Questions on new recruitment campus

Campus Drive

Usually, this interview takes 40 to 60 minutes and may have one or two interviewees. By posing behavioral questions, one interviewer will concentrate on your communication skills, self-management skills, and context. The other will focus on your technical skills.

Telephonic interview

If TCS will not come to your school this fall, so you will have submitted your resume online this fall. You look great on paper and they want a job discussion with the candidate. They will schedule your phone interview with a mutually acceptable date and time. By asking behavioral questions the interviewer will determine the communication abilities, self-management skills, and context. He/she may evaluate your technical ability, too. If the interview on the phone goes well, you’ll be asked to join us for an interview in person.

TCS Recruitment 2020

TCS Questions for Technical Interview

Please note: You should determine your Favorite programming language before the interview and be prepared based on that question.

Here are some of the differences between Java and C language.

C was developed by Dennis M. Ritchie between 1969 and 1973.Java was developed by James Gosling in 1995.
C is a Procedural Programming Language.Java is Object-Oriented language.
C is more procedure-oriented.Java is more data-oriented.
C is a middle-level language because binding of the gaps takes place between machine level language and high-level languages.Java is a high-level language because translation of code takes place into machine language using compiler or interpreter.
C is a compiled language that is it converts the code into machine language so that it could be understood by the machine or system.Java is an Interpreted language that is in Java, the code is first transformed into bytecode and that bytecode is then executed by the JVM (Java Virtual Machine).
C generally breaks down to functions.Java breaks down to Objects.
C programming language can be used for system programming as well as Application programming.This is not the case in Java.
C does not contain the property called Inheritance because it does not support OOPS, which is very useful for code reusability. Thus C is not suited when one has to relate the things according to the real world.Java contains the property of Inheritance which is very useful in code reuseability.
Memory allocation can be done by malloc in CMemory allocation can be done by a new keyword in Java.
C is a low-level language. It has difficult interpretation for the user but it has a closer significance to the machine-level code.Java is a high-level language because translation of code takes place into machine language using compiler or interpreter.
In C89 declaration of variables is at the beginning of the block but in the latest version of C that is C99 we can also declare variables anywhere.We can declare variables anywhere.
free is used for freeing the memory in C. A compiler will free up the memory internally by calling the garbage collector.

C does not supports Threading.Java supports the concept of threading.
C supports pointers.Java does not supports pointers.
It is not portable.It is portable.
Call by value and call by reference is supported in C.It only supports a call by value.
C is platform dependent.Java is a platform independent.
It supports user-based memory management.It internally manages the memory.
C is not robust that is strict type checking does not takes place while compile and run time.Java is robust.
Exception handling cannot be directly achieved in C and thus it lacks the maintenance of normal flow of the program.Exception Handling is supported in Java.
It follows a top-down approach.Java follows a bottom-up approach.
Overloading functionality is not supported by C.Java supports method overloading which helps in code readability.
C supports Preprocessors.Java does not support Preprocessors.
C does not supports OOPS concept.Java supports OOPS concept.
Union and structure datatypes are supported by C.Java does not supports union and structures.
C supports the storage classes.Whereas Java does not suport the storage classes.
It has 32 keywords.It has 50 keywords.
Go-to statements are supported in C language.Java does not supports go-to statements.
Virtual keywords are supported by C.Virtual keywords are not supported by Java.
Overloading functionality is not supported by C.Java supports method overloading which helps in code readability.
Default members of C are public.Default members of Java are private.
Data hiding is done by using static in C.Data hiding is done by using private in Java.

Functions inside the header file are declared. That is there are function prototypes in a header register, not function bodies. They are set in the library (lib).

There are four types of classes of storage in C. They are local, auto-registration and static

Static is a qualifier for access. If a variable within a function is declared static, the scope is restricted to the function, but it will exist for the program ‘s lifetime. Values between consecutive calls to a function will persist

Macros are processor instructions that will be substituted at the time of compile. The downside with macros is that they actually substitute the code they do not function calls. Likewise, the advantage is that they can reduce the replacement time for the same values.

Pass by value actually transfers the value from the caller to the calling function, so that the call function can not change the caller function values. But Pass by reference will pass the address instead of the value to the caller function if the call function requires modifying any value that it can directly modify.

An object is an abstract type of data that adds polymorphism and heritage. Instead of structuring programs as code and data, an object-oriented system integrates the two using an “object” concept An object has state and actions (code) (data).

A class is a user-defined blueprint or prototype which creates objects from. It represents the set of properties or methods that all objects of one form have in common. Class declarations may generally include certain components, in order to:

Modifiers: A class can be public or has default access (For information see this).
Class name: Initial letter (capitalized by convention) will start the name.
Superclass(if any): extends the name of the parent (superclass) of the class, where any, followed by the keyword. A class can only apply to one parent (subclass).
Interfaces(if any): A comma-separated list of class-implemented interfaces, if any, followed by keyword resources. More than one interface can be implemented by a class.
Body: The body of the class surrounded by braces,}.

Constructors are employed to create new objects. Fields are variables that provide the state of the class and its objects, and methods are used to enforce the class and its object’s behavior.

Here you will learn about class and structure differences.

A class and a structure, are user-defined data types and often it may be difficult to understand the difference between the two. The following table indicates strong differences between the two to understand this.

It is a reference data type and uses the keyword “class”.It is a value data type and uses the keyword “struct”.
Object for a class is created in the heap memory.Object for a structure is created in the stack memory.
We can always inherit another class. i.e., the concept of inheritance is applied.Structures can never be inherited.
Object is created using the “new” keyword.We may or may not use the keyword “new” while creating objects.
It occupies more space.A structure occupies less space.
Class allows both the parameterized and the non parameterized constructors.It only allows for the parameterized constructors, even the default constructors cannot be used.
class fruits {
Fruit F1;
F1.apple= “red”;
public struct fruit {
public string apple;
public string mango;

POINTER is a variable where the address of another variable is stored. A pointer function can also be used to refer to another pointer. A pointer may be incremented/decremented, i.e. pointing to the next/previous location of the memory. The purpose of the pointer is to save memory space and attain faster execution time.

How does Pointer Work?
If we declare a form int variable v, then v will actually store a value.

Int v = 0;
V now equals zero.

However, each variable has its address (or, simply put, where it is located in the memory, apart from the value). The address is retrievable by placing an ampersand (&) before the name of the element.

If you print a variable ‘s address on the screen, it will look like a completely random number (which can also be different from running).

Null pointer is a special attribute reserved for a reference. Every sort of pointer has the reserved value. Formally, each particular type of pointer (int *, char *, etc.) has its own dedicated null-pointer value. Conceptually it does not point anywhere when a pointer has that null value.

Void pointer is a different type of pointer-void *-a pointer pointing to any storage location of data which has no particular form.

Void pointer is a different type of pointer-void *-a pointer pointing to any storage location of data which has no particular form.

Null pointer is a value, then again, while the void pointer is a sort. Such definitions are entirely different, and they are incomparable. That basically means your question isn’t exactly true, as mentioned. For example, it’s like asking: “What’s the difference between a triangle and a car?”

Overloading function is a feature where two or more functions may have different parameters but the same name. Definitions of the polymorphism feature may be called function overloading.

          	#include <iostream> 
				using namespace std; 

				void print(int i) { 
					cout << " Here is int " << i << endl; 
				void print(double f) { 
					cout << " Here is float " << f << endl; 
				void print(char const *c) { 
					cout << " Here is char* " << c << endl; 

				int main() { 
					return 0; 

Function overloading : A feature in programming languages that allows multiple functions of the same name can be described with different parameter types or with different parameter numbers. This feature is called the Overloading method. The compiler can determine the correct function by evaluating the number of parameter types/arguments within the overloaded function. Function overloading eliminates the expenditure in different feature names and allows the use of more than one feature to perform similar functionality.

Operator overloading : A feature in programming languages that permits operators to be redefined. This functionality works on objects identified by the user. All overloaded operators have equal syntactic sugar for function calls. Operator overloading offers a nice façade without contributing to / altering the underlying language changes.

A class friend function is specified outside the boundaries of that class but it has the right of access to all private and protected class members. While the prototypes for friend functions appear in the concept of class, friends are not functions of students.

A friend can be a function, function template, or member function, or a class or class template, in which case friends are the whole class and all its members. To announce a function as a class friend, precede the prototype function with keyword friend in the class description

One important feature of C++ is the inline function. So let’s first understand why inline functions are being used, and what is the inline function purpose?

Once the program executes the function call instruction the CPU will store the instruction’s memory address after the function call, copy the function arguments on the stack and finally pass power to the required function. The CPU then executes the function code, stores the return value of the function in a predefined location/register of the memory, and returns control to the calling function. This can become overhead if the task execution time from the caller task to call the function (callee) is less than the switch time. The overhead of the function call is generally negligible relative to the amount of time the function takes to run for functions that are large and/or perform complex tasks. However, for small, commonly used functions, the time required to make the call to the function is often much longer than the time required to actually execute the code for the function. With small functions, this overhead arises because small function execution time is less than the switching time.

C++ provides inline functions for lowering overhead call functions. Inline function is a function which is expanded when it is called in line. When the inline function is called entire inline function code is added or substituted at the inline function call stage. The C++ compiler performs this substitution during compile time. Where low, inline feature will improve performance.

    	      		inline return-type function-name(parameters) {
			    		// function code

A class that is declared using the keyword “abstract” is known as abstract. It can have both abstract methods (methods without body) and concrete methods (regular body methods). Can not provide abstract methods in a typical class(non-abstract class). In this guide, we’ll learn what an abstract class is, why we use it and what are the rules that we need to follow when working in Java with it.

You can not instantiate an abstract class, which means you are not allowed to create an object of it. Why? For what? We’ll explore that in this guide later.

– An existing memory block which was allocated by subroutine malloc) (will be freed by subroutine free). When an invalid pointer parameter is transferred, there will be unpredictable effects. Unless the parameter is a null-pointer then there will be no intervention.

– Since the subroutine realloc) (allows the developer to adjust the block size of the memory pointing to the pointer parameter, a given byte size is returned through the size parameter and a new pointer is returned to the block. The specified pointer parameter must have been created by using the subroutines malloc(), calloc) (or realloc) (and should not be dealt with by subroutines realloc) (or free). If the parameter of the pointer is a null pointer then there will be no action.

All Arrays and Linked List can be used to store similar types of linear data, but they do have some advantages and disadvantages over each other.

Key Differences Between List and Array

  1. An array is the data structure that contains a collection of similar data elements of the sort while the Linked list is considered a non-primitive data structure that contains a collection of unordered linked elements known as nodes.
  2. The variables belong to indexes in the sequence, i.e. if you wish to enter the fourth element, you must write the name of the variable with its index or position within the square bracket.
  3. However, you must start from the head in a linked list and work your way through until you get to the fourth element.
  4. It’s quick to access an element in an array, while Linked list takes linear time, so it’s a bit slower.
  5. Much time consumes operations such as insertion and deletion in arrays. On the other hand, these operations perform fast on Linked lists.
  6. Arrays are of fixed dimensions. Conversely, Linked lists are dynamic and flexible, and their size can be expanded and contract.
  7. At compile time, memory is allocated in an array, while it is allocated at execution or runtime in a Linked list.
  8. Elements are placed in arrays consecutively, while they are placed randomly in Linked Lists.
  9. The memory requirement is less because the actual data is stored in the array inside the index. As well, due to the storage of additional next and previous referencing items, there is a need for more memory in Linked Lists.
  10. Additionally, the use of memory in the array is inefficient. Conversely, the use of the memory in the linked list is efficient.

Difference between Structure and Array

Array refers to a collection consisting of elements of the homogenous data type.Structure refers to a collection consisting of elements of the heterogenous data type.
Array uses subscripts or “[ ]” (square bracket) for element accessStructure uses “.” (Dot operator) for element access
Array is pointer as it points to the first element of the collection.Structure is not a pointer
Instantiation of Array objects is not possible.Instantiation of Structure objects is possible.
Array size is fixed and is basically the number of elements multiplied by the size of an element.Structure size is not fixed as each element of Structure can be of different type and size.
Bit filed is not possible in an Array.Bit filed is possible in an Structure.
Array declaration is done simply using [] and not any keyword.Structure declaration is done with the help of “struct” keyword.
Arrays is a primitive datatypeStructure is a user-defined datatype.
Array traversal and searching is easy and fast.Structure traversal and searching is complex and slow.
data_type array_name[size];struct sruct_name{
data_type1 ele1;
data_type2 ele2;
Array elements are stored in continuous memory locations.Structure elements may or may not be stored in a continuous memory location.
Array elements are accessed by their index number using subscripts.Structure elements are accessed by their names using dot operator.

A data structure is a specific way to organize data in a computer so it can be used effectively.

For example, using the array data structure, we can store a list of items having the same data-type.

The data structure is important where data is involved in almost every aspect. Algorithms that require an efficient data structure are typically implemented in the following areas: numerical analysis, operating system, A.I., compiler design, database management, graphics, and statistical analysis, to name a few.

Code Reusability and Readability are the key benefits of inheritance. When child class inherits parent class properties and features, we do not need to write the same code in child class again. This makes reuse of the code easier, makes us write less code, and the code becomes much more legible.

What is Deadlock?
There was a time when operating systems could only execute one process at a time, thereby giving full system resources and attention to that one process. Operating systems today can perform several tasks at once, but they often have to deal with a dilemma known as a stalemate. A deadlock occurs when there is at least one process that is waiting for another process to release resources in order to complete a task correctly.

Prevention & Avoidance:
A deadlock may occur if and only if all of the following conditions in a system are met at the same time. These terms are referred to as the Coffman conditions:

  1. Mutual exclusion states that each resource may only be allocated to one process at a time
  2. Circular waiting means that a process has a resource and needs some of the resources that other processes carry
  3. Keeping resources is where one or more processes will maintain and wait for other resources to be available for use
  4. No preemption means the resources which have already been granted access and which can not be removed at that time

If you are aware of these four conditions, you will be able to follow them and hopefully avoid a complete deadlock. In a deadlock situation, there may also be a slight variation in which there are two or more processes in a constantly changing state known as livestock. The crucial difference here is that the processes at play did not necessarily cease at all but rather were just too busy to respond to each other.

The limitations of singly-linked lists:
The Single Linked List (SLL) is a linear data structure that consists of nodes chained in one direction. Each node contains a data member that holds useful information and a pointer to the following node.
The problem with this structure is that it only allows us to traverse forward, i.e. when required, we can not iterate back to a previous node.

This is where the Connected Double List (DLL) shines. DLLs are an extension of connected basic lists, with one exception only:

A doubly connected list requires a pointer to the next node and to the previous node. This means you can navigate the list in both directions.

The class of the doubly linked list:
From the above definition we can see that there are three fundamental members to a DLL node:

– The data
– A pointer to the next node
– A pointer to the previous node

Despite the inclusion of a p (previous) pointer, a DLL costs more in terms of memory. The reward for this, though, is that iteration gets much more effective.

Complexity in time
The worst-case search, insertion, and deletion complexity is O(n). Can be added and removed at the head in O(1).

Have you ever wondered how different views different users can have on the same website? A college website, for example, has a different view for the student , faculty and dean. A student can see his / her attendance information, homework, etc .. When a faculty can see its class time-table as well as all the details relevant to a faculty. We see only that much needed data and other data is hidden from us. So, what is the name for this phenomenon? Yeah, you were right. This phenomenon is termed abstraction of data. We’ll hear about data abstraction in this blog and we’ll see the three abstraction levels in DBMS, too. So let’s get going.

Data Abstraction:
Data Abstraction refers to the process whereby the user hides irrelevant information. So, what would irrelevant details mean? Let’s get this through with one case. Example: If we try to access some mail from our Gmail then we don’t know where that data is stored physically i.e. is the data present in India or USA or what data model was used to store that data? We are not preoccupied with these issues. Our email is just about us. So, information like this i.e. location of data and data models is irrelevant to us and we only do this in data abstraction. There are other variables that we don’t know about besides the position of data and data models.

There are mainly three levels of data abstraction and to achieve data independence we divide it into three levels. Data independence ensures that users do not need to communicate directly with each other and data does not. The consumer should be at another level, and the data should be present at a different level. Data Independence can be accomplished by doing so. Now let’s see in-depth what these three abstract types of data are:

1: View Level
2: Conceptual Level
3: Physical Level

View Level or External Schema
This level informs the application of how the user should be displaying the data. Example: If in a university system we have a login-id and password, then as a student we can see our marks, attendance, fee structure, etc .. Yet the University’s faculty will have a particular view. He would have choices such as pay, editing a student’s grades, joining the student’s attendance, etc. The student and the teachers, then, have a different view. In doing so, system protection also improves. The student can’t edit his marks in this example but the faculty that is authorized to edit the marks can edit the marks of the student.

Conceptual Level or Logical Level
This level says how actually the data is processed and organized. We have different data models from which we can store the data(from here you can learn more about the different data model types). Example: Take an example where the relational model is used to store the data. We must store a student ‘s data, the student table columns will be student name, age, mail id, roll no, etc. At this point, we have to describe all these when we are building the database. Although the data is stored in the database, the structure of the tables, such as the student table, teacher table, book table, etc., is described in the conceptual or logical level here.

Physical Level or Internal Schema
The physical level, as the name implies, informs us about where the data is actually stored, i.e. it informs the user ‘s actual location of the data. The Database Administrators(DBA) decide which data should be stored at which particular disk drive, how to fragment the data, where to store it, etc. They are deciding whether to centralize or disperse the data. While at view level we see the data in the form of tables, the data here is actually only stored in the form of files. It totally depends on the DBA, how physically he/she handles the database.

An argument on the command line allows you to provide input from outside the system to your software. Nearly every programming language accepts arguments from the command line.

Only one simple example:-

Using command-line logic, let ‘s find the sum of two integer numbers:

          	#include <stdio.h>
				int main(int argc, char *argv[])
					int a,b;
						return -1;
					a = atoi(argv[1]);
					b = atoi(argv[2]);	
					return 0;

What is a Storage Class:
A storage class represents a variable ‘s visibility, and location. It says how much code we can access a variable from. The following things are described by a storage class:

  1. Scope variable.
  2. The position the variable is stored in.
  3. The value initialized in a variable.
  4. A variable lifespan.
  5. What can get into a variable?

Therefore, the information about a variable is represented by a storage class. There are a total of four standard class storage types. The table below shows the types of capacity in ‘C’

Storage classPurpose
autoIt is a default storage class.
externIt is a global variable.
staticIt is a local variable which is capable of returning a value even when control is transferred to the function call.
registerIt is a variable which is stored inside a Register.

The alignment of the data structure is the way that data is organized and stored in computer memory. Data alignment and padding of the data structure are two separate things but are related to each other and known as Data Structure Alignment together.

Data alignment: Data alignment involves placing the data at address in memory equal to certain word size multiples. This improves device efficiency because of the manner in which the CPU manages memory.

Data Structure Padding: Now, to fit the data, some extra bytes which need to be added between the end of the last data structure and the start of the next data structure, because the data is stored in memory because multiples of fixed word size. This addition of extra memory bytes to match the data is called padding of the data structure.

A new operator is a feature that allocates raw memory — conceptually at least, it’s not much different from malloc). Although it is very rare when you write anything in your own container, you can directly call a new operator, such as:

char *x = static_cast(operator new(100));

Overloading of the new operators is also possible either globally, or for a particular class. IIRC, is signed by:

void *operator new(size_t);

Of course, if you overload a new operator (whether global or for a class), you will also want/need to delete the matching operator too. For what it’s worth, there’s also a separate new operator] [that’s used to allocate memory to arrays — but you’re almost certainly better off totally ignoring that entire mess. The new operator is what you normally use to build a free-store object:

my_class *x = new my_class(0);

The difference between the two is that only raw memory is allocated by a new operator, nothing else. The new operator begins with the use of a new operator to assign memory, but then invokes the constructor for the proper form of entity, 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) then those builders are also invoked.

The delete and delete operators] [are used to remove the objects generated with new and new], [returning to the allocated memory left available to the compiler’s memory manager, respectively.

Objects created with new must obviously be deleted and the arrays created with new] [should be removed].

A) Recursive is a function that calls itself.
B) Recursive program speed is slower because of overhead stacking.
C) The recursive function must be subject to recursive conditions, terminating conditions, and recursive definitions.

Stack the structure of data. It remembers its caller because of its LIFO (Last In First Out) property, so it knows who to return when the function has to return. Recursion allows the use of device stack to store function calls return addresses. Each recursive function has it’s corresponding iterative (non-recursive) function. Even when these equivalent iterative procedures are written, it is necessary to use the explicit stack.

This is a translator that takes input, i.e. high-level language, and generates low-level language output, i.e. machine language or assembly language.

  1. The compiler is smarter than assembler which checks all kinds of limitations, ranges, errors, etc.
  2. But it’s more system run time and takes a greater portion of memory. It is slow because a compiler runs through the whole program and then translates the whole program into machine codes.

An interpreter is a program that converts the language of the programming into an understandable language. –

  1. This merely translates one program assertion at a time.
  2. Most often than not, the interpreters are smaller than compilers.

Let’s see the difference between Compiler and Interpreter:

1.Compiler scans the whole program in one go.Translates program one statement at a time.
2.As it scans the code in one go, the errors (if any) are shown at the end together.Considering it scans code one line at a time, errors are shown line by line.
3.Main advantage of compilers is it’s execution time.Due to interpreters being slow in executing the object code, it is preferred less.
4.It converts the the instructions into systematic code.It doesn’t convert the instructions instead it directly works on source language.
Eg.C, C++, C# etc.Python, Ruby, Perl, SNOBOL, MATLAB etc.

Applet is a java program that can be inserted into the HTML pages. Java applets running on the java allow Web browsers like Mozilla and internet explorer. The applet is designed to run on the client-server remotely, so some limitations apply. Applets can not access local computer resources from the system. Applets are used to make the Website more fun and interactive.

Garbage Collector is a program that automatically manages memory, where Java performs the de-allocation of objects rather than the programmer. In the Java programming language, the new operator is used to achieve the dynamic allocation of objects. An object once created uses some memory, and the memory remains allocated until references are made for the object to be used.

If there are no references to an object, it is assumed that it is no longer necessary and it is possible to reclaim the memory occupied by the object. There’s no explicit need to destroy an object because Java automatically handles the de-allocation.

Garbage Collection is known as the technique that accomplishes this. If there is no memory left in the system to allocate, programs that do not de-allocate memory can eventually crash. Those programs are said to have leaks of memory.

Garbage collection in Java occurs automatically during program lifetime, eliminating the need for memory de-allocation and thus avoiding memory leakage.

In C language it is the duty of the programmer to de-allocate the dynamically allocated memory using the free) (function. This is where the administration of Java memory leads.

In C language it is the duty of the programmer to de-allocate dynamically assigned memory using the free) (function. That is where control of the Java memory is going.

In the presence of malicious third parties — known as adversaries, cryptography allows for secure communication. Encryption converts an input (i.e. plaintext) into an encrypted output ( i.e., ciphertext) using an algorithm and a key. If the same key is used, a given algorithm will always convert the same plaintext into the same ciphertext.

Algorithms are considered safe if, given the ciphertext, an attacker is unable to determine any of the plaintext or key properties. Given a large number of plaintext/ciphertext combinations that used the key, an attacker should not be able to determine anything about a key.

1 people reacted on this

  1. […] UPCOMING JOBS 21 React js Interview Questions and Answers | Shaga Org Ltd is hiring Data Entry Executive, Computer Data Entry Operator!!! | Altius BPO India Current Jobs 2020 | Accel Frontline Current Jobs Opening 2020 | Suvidha Talent Careers 2020 | Shinhan Bank Current Jobs 2020 | Backend Developer for a Product Based Company – Bengaluru, Karnataka | Technical Leader required at Cisco | Cisco Systems is hiring for C/C++ developers in India | TCS Possible Technical Interview Questions and Answers | […]

Leave a Comment