Cognizant Interview Questions and Answers for 2024

Cognizant is a multinational technology company providing digital, technology, consulting, and operations services to various industries. The company offers various services, including digital strategy, artificial intelligence, cloud computing, cybersecurity, data analytics, and more. It serves clients in banking, healthcare, retail, manufacturing, and telecommunications. The interview process at Cognizant can vary depending on the position and location, but it involves several rounds of interviews. If you're preparing for the first time or preparing for an advanced-level Cognizant interview, our set of Cognizant interview questions with answers will help you prepare for the interview in the most effective way.

  • 4.7 Rating
  • 50 Question(s)
  • 25 Mins of Read
  • 6117 Reader(s)

Beginner

An exe is an executable programme, but a DLL is a file that may be dynamically loaded and run by applications. It is a program's external code repository. Because they are separate apps, they should share the same DLL rather than having that code in their files. It also minimises the amount of storage space necessary.

#include <iostream> 
using namespace std; 
int main() 
{ 
char str[100]; 
int len = 0; 
cout << "Enter a string: "; 
cin >> str; 
while(str[len] != '\0') 
{ 
len++; 
} 
cout << "Length of the given string is: " << len; 
cout << endl; 
return 0; 
} 

It's no surprise that this one pops up often in Cognizant interview questions.

We may get the address of any variable by using the "address of operator" (&) operator, which returns the variable's address. 

#include <stdio.h> 
int main(void) 
{ 
// declaring the variables  
int x; 
float y; 
char z; 
printf("Address of x: %p\n", &x); 
printf("Address of y: %p\n", &y); 
printf("Address of z: %p\n", &z); 
return 0; 
} 
  • Proactive Updates: These are modifications made to the database before it is used in the actual world. 
  • Retroactive Updates: These are changes made to a database after it has been operational in the real world. 
  • Simultaneous Updates: These updates are made to the database at the same time they become operational in the actual world. 

The fill factor is the proportion of space that will be filled with data on each leaf-level page. A page, which is made up of 8K pages, is the smallest unit in SQL Server. Each page can hold one or more rows, depending on the size of the row. The default value for the Fill Factor is 100, which is the same as the number 0. If the Fill Factor is set to 100 or 0, the SQL Server will fill the leaf-level pages of an index with the maximum number of rows that can fit. When the fill factor is set to 100, there will be no or very little empty space on the page.   

Black box testing is the process of testing an application without knowing anything about its internal structure or code implementation. On black box testing, testers would be concerned with the functionality of the program rather than data flow and code execution in the back end.

White box testing is the process of testing an application while knowing its internal structure and code implementation. In most cases, this testing is done by the developer who wrote the code in the form of unit tests.

Expect to come across this popular question in Cognizant interview questions for freshers.

Index hunting is a technique for increasing the number of indices in a collection. Indexes are used to increase query performance as well as query processing time. 

It helps to enhance query performance in the following ways: 

  • The query optimizer is used to recommend the best queries. 
  • Index, query distribution, and performance factors are employed to test the effect. 
  • Databases are optimized to focus on a narrow set of issue queries. 

The Exterior Gateway Protocol (EGP) is a protocol that allows Internet gateways from the same or other autonomous systems to communicate information about network reachability.

EGP is used for three main purposes: 

  • Make a list of neighbors. 
  • Keep an eye on your neighbors (to see if they are still alive and reachable). 
  • Inform your neighbors about the networks that their autonomous systems can access. 

The information about nested method (recursive) calls is kept in the stack, which is a section of memory that extends all the way down to the current programme address. It also includes all heap references and local variables defined in the currently running operations. This structure enables the runtime to erase all local variables and return from the method knowing the address from which it was called when the procedure is terminated. Each thread has its own stack. For dynamic allocation, a sizable quantity of memory is used called the heap. When you use the new keyword to create an object, heap space is allocated. In contrast, the stack stores the reference to this object.  

When an object becomes garbage collection eligible, the Garbage Collector (GC) must invoke the finalize method on it. The GC labels the item as finished and sets it away until the next cycle since the finalize method can only be used once. 

In the finalize method, you may potentially "resurrect" an object by assigning it to a static field, for example. The object would resurrect and become ineligible for trash collection, preventing the GC from collecting it in the following cycle. 

The object, on the other hand, would be tagged as completed, which means that when it became eligible again, the finalize method would not be called. In other words, you can only utilize this "resurrection" approach once. 

// Java Program to illustrate Object Resurrection 
import java.io.*; 
import java.util.*; 
public class KnowledgeHutprivate int num; 
// Constructor 
public KnowledgeHut(int num) 
{ 
// assigning the parameter value to the member variable 
this.num = num; 
} 
static final ArrayList<KnowledgeHut> ar = new ArrayList<KnowledgeHut>(); 
protected void finalize() throws Throwable 
{ 
System.out.println("Resurrect " + num); 
// By using the this operator, adding the current instance to object 
ar.add(this); 
} 
public String toString() 
{ 
return "Element(" 
+ "number = " + num + ')'; 
} 
public static void main(String[] args) 
throws InterruptedException 
{ 
for (int i = 0; i < 3; i++) 
ar.add(new KnowledgeHut(i)); 
for (int j = 0; j < 5; j++) { 
 
System.out.println("The Elements are : " + ar); 
// Clearing off elements 
ar.clear(); 
// Calling the garbage collector function 
System.gc(); 
// Making the thread to sleep for 500 ms 
Thread.sleep(500); 
} 
} 
} 

Output: 

The Elements are : [Element(number = 0), Element(number = 1), Element(number = 2)] 
Resurrect 2 
Resurrect 1 
Resurrect 0 
The Elements are : [Element(number = 2), Element(number = 1), Element(number = 0)] 
The Elements are : [] 
The Elements are : [] 
The Elements are : [] 

Explanation: The finish technique adds things to the collection just once before resurrecting them. They have been tagged as completed and will not be queued again when picked up a second time.  

A software metric is a quantitative measure of program attributes. Software metrics may be used for a variety of purposes, including assessing software performance, planning, projecting productivity, and so on. Some software measurements are load testing, stress testing, average failure rate, code complexity, lines of code, and so on. The advantages of software metrics are numerous, including the following: 

  • It lowers the cost. 
  • It raises ROI (return on investment). 
  • Reduces workload. 
  • Highlights areas for improvement.

A constant pointer is one that cannot change the address of the variable to which it points. Once a const pointer is set to point to one variable, it cannot be changed to point to another variable. This pointer is known as a const pointer. 

This is a common Cognizant interview question, be prepared for it. 

A Software Project Manager is in charge of steering the project to the conclusion. The Software Project Manager's role is to ensure that the entire team follows a methodical and well-defined approach to software development. 

A software project manager is also in charge of the following duties: 

  • Project preparation 
  • Monitoring project status 
  • Resource administration 
  • Risk administration 
  • Project completion on schedule and under budget. 

Compilation is the process of transforming high-level source code to low-level machine code. A compiler is a piece of software that does the compiling. If the source code is error-free, the compiler checks it for syntactical and structural flaws and creates object code with the extension.obj (in Windows) or.o (in Linux).

The practice of recording and regulating changes that occur during the software development lifecycle is known as software configuration management. Any modification made during software development must be tracked using a well-defined and regulated methodology. 

Configuration management guarantees that all modifications performed during software development follow a well-defined protocol. 

rvalue is the expression that appears on the right side of the assignment operator. Rvalue is assigned to alvalue on the assignment operator's left side. The lvalue should denote a variable rather than a constant.

  • The memcpy() method copies a given number of bytes from one memory to another. 
  • The strcpy() function, on the other hand, is used to copy the contents of one string into another. 
  • The memcpy() method manipulates memory rather than values. In contrast, the strcpy() method operates on values rather than memory. 

The scope of software is a well-defined limit. It encompasses all actions performed in the development and delivery of the software product. 

The software scope describes all the software's functionalities and artefacts. What will the product perform is also specified in the scope. What does not belong to the project? What exactly does project estimation entail? 

This procedure is useful for estimating several characteristics of the software product. This estimate can be determined by speaking with experts or by applying pre-defined formulas. 

The variable declaration informs the compiler about the variable's data type and size. Variable definition, on the other hand, allocates memory to the variable. 

In a program, variables can be defined many times. However, a variable in a program can only be defined once. 

Variable declaration is used to assign attributes and identify variables. A variable definition, on the other hand, is for assigning storage space to a variable. 

Create a method that calculates the distance between a and b, getDistance(a, b). 

Code: 

import java.util.HashMap; 
import java.util.Map;  
import java.util.PriorityQueue;
public class PrioRQueueExample { 
public static void main(String[] args){ 
PriorityQueue<Double> pq = new PriorityQueue<Double>((x,y)-> {Double z = y-x;return z.intValue(); }); 
PrioRQueueExample pqe = new PrioRQueueExample(); 
//Number of ATMs to return i.e. K 
int num_ATMs = 3; 
double curr_loc = 0.00; 
Map<String,Double> nallATMLocs = new HashMap<String,Double>(); 
//Map of ATM names and their distance co-ordinates 
nallATMLocs.put("atm1",45.0); 
nallATMLocs.put("atm2",78.0); 
nallATMLocs.put("atm3",54.0); 
nallATMLocs.put("atm4",64.0); 
nallATMLocs.put("atm5",35.0); 
nallATMLocs.put("atm6",42.0); 
nallATMLocs.put("atm7",57.0); 
nallATMLocs.put("atm7",1.00); 
nallATMLocs.forEach((atm,dist) ->{if(pq.size() < num_ATMs){ 
pq.add(pqe.getLocation(curr_loc,dist));} 
else{ 
if(        pq.peek() > pqe.getLocation(curr_loc,dist)){ 
pq.poll(); 
pq.add(pqe.getLocation(curr_loc,dist)); 
} 
} 
}); 
 q.forEach(atmLoc -> System.out.println(atmLoc)); 
} 
private double getLocation(double curr,double atm){ 
return atm - curr; 
} 
} 

integer I = 5; integer j = i++; 

When these operators are applied before a variable, the variable's value is modified first, and then the modified value is utilized. For example, if we changed the previous code to say int j = I I would be increased to 6 and then j would be assigned to that new value, resulting in both being equal to 6. 

When these operators are followed by a variable, the variable's unmodified value is utilized, and then it is incremented or decremented. 

As a result, in the expression int j = i++; in the above code sample, j is initially set to the unaltered value of I (i.e., 5) and then I is increased to 6. 

These are some of the most frequently asked Cognizant interview questions. 

A view is a single table in SQL that contains data from other tables. As a consequence, a view has similar rows and columns to an actual table, as well as fields from one or more tables. 

To make a view, do the following: 

CREATE VIEW View_Name AS 
SELECT Column1, Column2, Column3, ..., ColumnN 
FROM Table_Name 
WHERE Condition; 

To update a view: 

CREATE VIEW OR REPLACE View_Name AS 
SELECT Column1, Column2, Column3, ..., ColumnN 
FROM Table_Name 
WHERE Condition; 

For expressing an opinion: 

DROP VIEW View_Name; 

Column1, Column2,... ColumnN represents the names of the columns to be added or modified in the queries above. View Name is the name of the newly constructed view, and Table Name is the name of the current table. 

A staple in Cognizant technical interview questions, be prepared to answer this one.

main() is an entry point (main function) in most programming languages. When the compiler starts compiling the program, it looks for an entry point, and main() acts as an entry point in C programs. We can also say that main is a thread/process/function that the compiler invokes automatically when the program is executed. 

Every function returns a value to the calling function; at that time, main will be a called function for the compiler/OS, and it will return some value to the compiler before exiting; the void and int specifies that main will return a void (nothing), while int will return an integer value to the compiler. 

A common question in Cognizant interview questions for experienced, don't miss this one.

SJF (Shortest Job First) is a scheduling policy that prioritizes the waiting process by executing it as soon as possible. Other names for it include Shortest Job Next (SJN) and Shortest Process Next (SPN) (SPN). It is a non-preemptive scheduling algorithm (that is, one process cannot snatch the resources assigned to a currently running process). 

The Shortest Remaining Time First variation of SJF scheduling is preemptive (SRTF). In this scheduling strategy, the process that is next in line and has the shortest time to completion is picked to be conducted. When several processes arrive at the same time, they change SRTF to SJF. 

Similarities: 

SJF and SRTF are both challenging to execute since the burst time of the processes cannot be predicted. 

Because lengthy processes can be delayed indefinitely if small processes are regularly introduced, both SJF and SRTF have the potential to create process hunger. 

SJF and SRTF are treated the same after all processes are in the ready queue. This is since no preemption occurs once the processes are assigned to the ready queue. 

Advanced

half limit unsigned char = 150; 
for (unsigned char i = 0; i&lt; 2 * half_limit; ++i) 
{ 
/ /take action; 
} 

The code will produce an endless loop. 

This is why: 

Based on C++ conversion rules, the expression 2 * half limit will be promoted to an int with a value of 300. However, because I is an unsigned char, it is represented by an 8-bit number that, when it reaches 255, will overflow (returning to 0), and the loop will therefore continue indefinitely. 

Over a more concrete file system, there is an abstract layer known as a virtual file system (VFS) or virtual filesystem switch. 

The goal of a VFS is to provide consistent access for client programmes to a variety of concrete file systems. For instance, a VFS enables access to both local and network storage resources without alerting the client device. 

It may be used to bridge the gap between Windows, classic Mac OS/macOS, and Unix filesystems, allowing applications to access files on those types of local file systems without knowing which file system they're working with. 

A VFS specifies how the kernel interacts with a particular file system. As a result, introducing new file system types to the kernel is straightforward. 

The volatile keyword alerts the compiler that a variable may change without the compiler being aware of it. Variables marked as volatile are not cached by the compiler and must constantly be read from memory. For class member variables, the mutable keyword might be used. Mutable variables can be changed from within the class's const member functions.

Caching is a method of storing several copies of frequently used data in a temporary storage space (or cache) so that they may be retrieved more rapidly. It stores data in a temporary format for software programs, servers, and web browsers, eliminating the need for users to download information every time they visit a website or use an application. 

Cached data works by storing information in a device's memory for later retrieval. The data is stored in a computer's memory, just beneath the central processor unit (CPU). The primary cache level is built into the microprocessor chip of a device, and it is followed by two secondary cache levels that feed the primary level. 

This information is stored until the content's time to live (TTL), which sets how long it should be cached, expires or the device's disc or hard drive cache fills up. 

Data is often cached in one of two ways: browser or memory caching (data kept locally on the computer) or Content Delivery Networks (data stored in geographically distributed locations). 

Variable declaration informs the compiler about the variable's data type and size. Variable definition, on the other hand, allots memory to the variable. 

Variables can be defined several times in a program. A variable in a program, however, may only be defined once. 

A variable declaration is used to assign properties and identify a variable. A variable definition, on the other hand, is used to assign storage space to a variable. 

Computer programs can use preemptive multitasking to share operating systems (OS) and underlying hardware resources. It divides overall operational and computing time among processes and switches resources between them based on predefined parameters. Preemptive multitasking is another term for time-shared multitasking. 

In cooperative multitasking, the operating system never initiates context switching from one process to another. A context switch occurs only when the processes willingly transfer control on a regular basis, or when they are dormant or logically blocked, allowing many programs to execute at the same time. Furthermore, all operations in this multitasking work together to make the scheduling technique function. 

  • The memcpy() method copies a given number of bytes from one memory to another. 
  • The strcpy() function, on the other hand, is used to copy the contents of one string into another. 
  • The memcpy() method manipulates memory rather than values. In contrast, the strcpy() method operates on values rather than memory. 

The practice of utilizing one program's output as an input to another is referred to as plumbing/piping. For example, rather than sending a folder or drive listing to the main screen, it may be piped and given to a file, or it can be sent to the printer to print a printed copy. 

In Linux and other Unix-like operating systems, a pipe is a sort of redirection (the movement of standard output to another place) that is used to convey the output of one command/program/process to another for extra processing. A command's stdout can be linked to another command's stdin on Unix/Linux platforms. This may be accomplished by using the pipe character '|'. 

The following are typical elements of a processed image: 

  • User data: This component of user space comprises program data, the user stack area, and programs that may be updated. 
  • The collection of instructions that will be performed by the user program. 
  • System Stack: Each process is coupled with one or more LIFO (Last In First Out) stacks. Parameters and calling addresses for procedure and system calls are saved here. 
  • Process control Block (PCB): Information required by the operating system to control operations. 

Translation TLB (Transaction Look-aside Buffer) is a cache that maintains track of recently used transactions. The TLB contains the most recently utilized page table entries. When a virtual address is handed to the CPU, it examines the TLB. If a page table entry (TLB hit) is present, the frame number is obtained and the actual address is generated. If a page table item is missing from the TLB (TLB miss), the page number is utilized as an index when processing the page table. The TLB first checks to see if the page is already in main memory; if it isn't, a page fault is issued, and the TLB is then changed to include the new page entry.

The resident set is the portion of the processed picture that is really in real memory at any one time. It has been subdivided into subsets, one of which is the working set. The working set is a subset of the resident set that is necessary for execution.

A network device that can function as both a bridge and a router is referred to as a bridge router, or brouter. Similar to a bridge, the router simply forwards packets necessary for established protocols. 

For routable protocols, brouters operate at the network layer; for non-routable systems, they operate at the data link layer. Brouters manage both routable and non-routable qualities by acting as bridges for non-routable protocols and routers for routable protocols. In an internetwork, routers and network bridges are both functions performed by brouters, which are networking equipment. 

You can look for more Cognizant HR interview questions in between this article. 

Rather than speaking in local "languages," all Telnet clients and servers agree to send data and instructions that adhere to the Network Virtual Terminal, a fictitious "virtual" terminal type (NVT). The NVT defines a set of standards for data formatting and transmission, including character set, line termination, and how to convey information about the Telnet session. 

On a terminal, any Telnet client may interact in both its native language and NVT. When a user enters data on a local terminal, it is converted to NVT and transmitted over the network in that format. 

When this information is received by the Telnet server, it is converted from NVT to the format required by the remote host. For transmissions from the server to the client, the same technique is used. 

The Hamming code is a collection of error-correction codes that may be used to detect and rectify faults that may occur during data transfer or storage from one source to another. Redundant bits are additional binary bits that are manufactured and added to the information-carrying bits of a data transmission to ensure that no bits are lost during the transfer. A parity bit is added to binary data to check if the total number of 1s is even or odd. 

Error detection is accomplished using parity bits. The Hamming Code is simply the use of extra parity bits to identify errors. 

A pair of virtual character devices known as a pseudo TTY offer a bidirectional communication channel (or "PTY"). The slave is at one end of the channel and the master is at the other. The slave end of the pseudo-terminal offers an interface that is identical to that of a normal terminal. A process that anticipates being connected to a terminal can open the slave end of a pseudo-terminal, which is then controlled by a program that has opened the master end. Anything written on the master end is sent into the slave end's procedure as if it were a terminal input. However, everything written to the slave end of the pseudo-terminal may be read by the process tied to the master end. Pseudo-terminals are used by network login services, terminal emulators, and other similar applications.  

BufferedWriter is a source of temporary data storage. It's used to generate a buffered character output stream with the output buffer size set to the default. 

The flush() method of the BufferedWriter class in Java is used to flush characters from the buffered writer stream to a file. 

It guarantees that all data items, including the last character, are written to the file. 

The close() method of the Java BufferedWriter class flushes the buffer stream and then closes it. Calling methods like write() and append() after the stream has been closed will result in an error.

Objects that are produced dynamically are kept in heap memory. If objects are produced without management, the memory will run out and the system will crash. 

A garbage collection algorithm is the Mark and Sweep algorithm. It operates in two stages. 

The technique discovers unneeded items in memory in the first phase, and these objects are deleted from memory in the second phase to reclaim the wasted space.  

These are some CTS interview questions

It may be constructed as numerous constructors with distinct arguments, each of which can do a separate activity. In Java, these constructors must have distinct signatures, and a separate set of arguments must be provided to the constructor for error-free compilation. 

public class Employee {  
intuid;  
String name;  
Employee(){  
System.out.println("this a default constructor");  
}  
Employee(inti, String n){  
uid = i;  
name = n;  
}  
public static void main(String[] args) {  
//object creation  
Employee s = new Employee();  
System.out.println("\nDefault Constructor values: \n");  
System.out.println("Employee uid : "+s.uid + "\nEmployee Name : "+s.name);  
System.out.println("\nParameterized Constructor values: \n");  
Employee Employee = new Employee(10, "John");  
System.out.println("Employee uid : "+Employee.uid + "\nEmployee Name : "+Employee.name);  
}  
} 

A virtual function is indeed a member function declared in the base class but overridden by the derived class. The use of virtual functions aids in the achievement of runtime polymorphism. 

  • Rules to remember while using virtual functions 
  • It cannot be fixed. 
  • It should be accessible through the use of a pointer or reference to the base class. 
  • A virtual destructor can exist in a class, but not a virtual constructor.  

A binary tree is a non-linear data structure. Every node in the tree has left and right pointers as well as data. The root node is the topmost node. Parent nodes have sub-nodes, but leaf nodes do not.

Binary trees are utilized in binary search tree implementation. They are handy for keeping records without taking up much space.

The divide and conquer method is used for Merge Sort. The issue is divided into smaller problems of the same type until they can be solved. 

The answer to the subproblemis then integrated with the solution to the original problem to create the solution. 

Merge sort has an O(n* log n) time complexity.

The process of anticipative multitasking allows computer programs to share operating systems (OS) and hardware resources. It switches resources across processes based on predefined parameters and allocates operating and processing time among them. Time-shared multitasking is another term for preemptive multitasking.

The fill factor specifies how much space will be given to data on each leaf-level page. The page, which is made up of 8K pages, is the smallest unit in SQL Server. The number of rows per page is determined by the row size. 

Fill Factor's default value is 100, which is the same as the number 0. When the Fill Factor is set to 100 or 0, SQL Server will try to fill the index's leaf-level pages with as many rows as feasible. When the fill factor is 100, there will be no or very little vacant space on the page. 

No employer wants a candidate who will depart the firm after only a few years. They predict that the applicants will be a strong match for the organization over the next 7-8 years. Even if you are doubtful, you must assure them that as long as the job you perform challenges you and contributes to a thriving firm, it will help you grow.  

These are some Cognizant interview questions that you shouldn’t skip. 

The C compilation process begins with the pre-processing of a source file. A pre-processor is a tiny piece of software that receives a C source file and performs the functions listed below. 

  • Remove comments from the original code. 
  • Macro expansion. 
  • Expansion of included header files. 

It creates a temporary file with the extension.i after pre-processing. Because it adds the contents of header files to our source code file. The pre-processor produced file is bigger than the original source file. 

Description

Summary: 

Cognizant interview process is not very hard and not very easy to crack. These were the top Cognizant interview questions and answers to give you a sense of what questions you could be asked and how to prepare for them. You may also enroll in a renowned Web Development syllabus to help you pass the interviews and land your dream job. 

Employers, in general, like to ask software engineers questions similar to Cognizant technical interview questions. Because there are so many developers, it is tough to select the best one, which is why technical tests are essential. 

Quality exists in code as well, albeit not all developers grasp what it is. So, if you're going to interview any developer, these questions will assist you in selecting the finest one. In addition, we hope you find these Cognizant Interview Questions and Answers beneficial in your interview preparations. While no one can predict the interviewer's questions, preparation is essential if you want to work for the business of your choice. Begin your job advancement by upskilling and reskilling yourself with knowledgeHut’s web development course curriculum and degrees from world-class universities. If you wish to learn coding and programming, consider enrolling in our PG program in full stack development. These comprehensive lessons will help you learn how to code and program. 

If you have any questions regarding the Cognizant Interview Questions lesson, please post them in the Cognizant Interview Questions comment box, and one of our experts will get back to you as soon as possible. 

Read More
Levels