0% found this document useful (0 votes)
53 views34 pages

Cognizant Interview Questions: Click Here

The document outlines the Cognizant interview process, including various technical and HR interview questions for freshers and experienced candidates. It details the recruitment stages, such as aptitude tests, technical interviews, and HR interviews, along with preparation tips and frequently asked questions. Additionally, it provides insights into Cognizant as a company, its eligibility criteria, and the types of roles available.

Uploaded by

EMUNA. D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views34 pages

Cognizant Interview Questions: Click Here

The document outlines the Cognizant interview process, including various technical and HR interview questions for freshers and experienced candidates. It details the recruitment stages, such as aptitude tests, technical interviews, and HR interviews, along with preparation tips and frequently asked questions. Additionally, it provides insights into Cognizant as a company, its eligibility criteria, and the types of roles available.

Uploaded by

EMUNA. D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Cognizant Interview Questions

To view the live version of the


page, click here.

© Copyright by Interviewbit
Contents

Cognizant Recruitment Process


1. Interview process.
2. Interview rounds.

Cognizant Technical Interview Questions: Freshers


and Experienced
3. Write the code to find the length of a string without using the string functions.
4. How will you print the address of a variable without using a pointer?
5. What do you understand about Proactive, Retroactive and Simultaneous Update
in the context of DBMS?
6. List out the differences between Generalization and Specialization in DBMS.
7. What is the fill factor in SQL? What is its default value?
8. What exactly is index hunting, and how does it aid query performance?
9. Write the steps to create, update and drop a view in SQL.
10. What are the similarities and the differences between Shortest Job FIrst (SJF)
and Shortest Remaining TIme FIrst (SRTF) CPU scheduling algorithms?
11. What factors influence whether or not a detection algorithm is required in a
deadlock avoidance system?
12. How does Dynamic Loading help in better memory space utilization?
13. What is Root Partition in OS?
14. What is the purpose of a Virtual File System (VFS)?
15. What is caching? How does caching work?
16. What is Preemptive Multitasking? How is it different from Cooperative
Multitasking?
17. What is plumbing/piping in Linux or Unix?
18. Name the typical elements of a processed image.
Page 1 © Copyright by Interviewbit
Cognizant Interview Questions

Cognizant Technical Interview Questions:


Freshers and Experienced (.....Continued)

19. What is Trapdoor in OS?


20. What is the Translation Lookaside Buffer?
21. What is the resident set and working set?
22. List the differences between RSA (Rivest, Shamir, Adleman) and Digital Signature
Algorithm (DSA).
23. What is a bridge router (als known as brouter) ?
24. What is Exterior Gateway Protocol (EGP)?
25. What do you know about Network Virtual Terminal (NVT)?
26. What is the Hamming Code?
27. What is the purpose of a Pseudo TTY (pseudo terminals)?
28. What is BufferedWriter? What are flush() and close() used for?
29. What is stored in each of the memory structures- stack and heap, and how are
they related to each other?
30. Is it possible to «resurrect» an object that has become eligible for garbage
collection in Java?
31. Is it possible to override and overload a static method in Java? Is it possible to
override a private method in Java?
32. What is monkey patch in Python?
33. Write the code to add two numbers without using arithmetic operators.
34. Write a code to print numbers from 0 to 100 in C++ without using loop and
recursion.

Cognizant Interview Preparation


35. Interview Preparation Tips

Frequently Asked Questions


Page 2 © Copyright by Interviewbit

Cognizant Interview Questions

Frequently Asked Questions (.....Continued)


36. Is cognizant interview difficult?
37. What is the fresher salary in Cognizant?
38. What are the questions asked in a Cognizant interview?
39. Is there any bond in Cognizant?
40. Does cognizant have a dress code?
41. How can I apply for Cognizant ?
42. How many rounds are there in a Cognizant interview?
43. How is career growth in Cognizant?

Page 3 © Copyright by Interviewbit


Let's get Started
Cognizant is a multinational technology company based in the United States that
specializes in business consulting, information technology, and outsourcing. The
company's headquarters are in Teaneck, New Jersey. Cognizant is a member of the
NASDAQ-100, S&P 500, Forbes Global 2000, and Fortune 500, and is one of the world's
most successful and fastest-growing organizations.
Cognizant assists businesses in modernising technology, reimagining processes, and
transforming customer experiences in order to stay ahead in an ever-changing
environment. It is determined to enhance the way the world works via technology,
whether it's by altering the companies that the world relies on or by providing the
tools and flexibility you need to develop the best you. Cognizant specializes in
information technology, information security, consulting, ITO, and BPO services.
Cognizant's business is divided into three areas: digital business, digital operations,
and digital systems and technology.
Cognizant offers a great opportunity for learning and creating a career path for
aspiring so ware engineers among all the MNCs offering Fresher Jobs in India.
Working here will expose you to a variety of new technologies as well as provide you
with the opportunity to work with global customers that will help you improve your
talents, problem-solving ability, and entrepreneurial spirit. Your ability to affect the
future of your career—and the world—is limitless at Cognizant.
Eligibility Criteria:

Page 4 © Copyright by Interviewbit


Cognizant Interview Questions

An applicant must have more than 60% marks in 10th and 12th (or diploma).
An applicant must have a minimum of 60% marks in graduation.
A er HSC(12th), but not a er SSC(10th), or between semesters of graduation, a
maximum interval of one year is permitted.
Graduation and post-graduation in BE, B Tech, ME, M Tech, MCA
At the time of the Cognizant selection process, a candidate should not have any
pending backlogs.

Cognizant Recruitment Process


1. Interview process.
From company culture to opportunities for growth, there are several things that
make Cognizant an excellent option to begin your career with. It provides a fantastic
workplace that encourages employees to develop and improve their skills conducive
to individual and company progress.
In this article, we've covered the entire Cognizant interview process as well as a
shared preparation method for acing the interview. This study is based on online
research and interviews with candidates who have recently appeared in the
Cognizant interview process.
For numerous jobs and departments, Cognizant hires both freshers and experienced
professionals. Cognizant visits numerous college campuses in their final placements
conducts walk-ins, and mega placement drives for fresher hiring. Cognizant primarily
hires experienced employees through its career website, HR consulting firms, and
employee referral programmes.
This season, Cognizant plans to run a recruitment process for four different positions.
The following are the specifics:
GENC
GENC ELEVATE
GENC PRO
GENC NEXT

2. Interview rounds.

Page 5 © Copyright by Interviewbit


Cognizant Interview Questions

Round 1: Aptitude test/Skill based assessment test


It is an online test that takes place on online platforms such as AMCAT etc.
Candidates applying for the GENC profile are required to appear for the aptitude test,
which contains the following sections:
Quantitative ability: This section will generally contain questions related to the
following topics: Basic Mathematics, Applied Mathematics, and Engineering
Mathematics
Logical reasoning: This section will generally contain questions related to the
following topics: Coding deductive logic, Data Sufficiency, Objective Reasoning,
Data Arrangement, Coding Pattern Recognition, Number Series Pattern
Recognition.
English comprehension: This section will generally contain questions related to
the following topics: Vocabulary (Synonyms, Antonym, Contextual Vocabulary),
Grammar (Error Identification, Sentence Improvement, and Construction),
Comprehension Reading.
Candidates applying for GENC NEXT, GENC PRO, and GENC ELEVATE profiles are
required to appear for the skill-based assessment test, which contains the following
sections:

Section Topics

MCQ Conceptual and Code Analysis

Coding Challenge Coding Questions

The questions will generally be related to the following topics :


Programming Constructs, Data Structures, Algorithms
Database/ SQL
Web UI

Page 6 © Copyright by Interviewbit


Cognizant Interview Questions

Based on their performances in skill-based assessment tests and interviews, one will
be selected for GENC NEXT, GENC ELEVATE, or GEN PRO profiles. Candidates should
have at least basic hands-on programming skills to qualify for the GenC Elevate
assessment, which should be substantiated by proof submitted during the self-
profiling procedure.
A er getting the required cut-off in the aptitude test/skill-based assessment test, the
candidates are selected for the technical interview round.

ROUND 2: Technical Interview


The technical face-to-face interview round is the most crucial in the entire interview
process. You should be well-versed in computer science fundamentals such as OOPS,
DBMS, CN, OS and be able to communicate them clearly to the interviewer.
Programming language knowledge is required. Make sure you're familiar with at least
one programming language. It is not necessary for you to be fluent in all
programming languages, but you should have sufficient experience with at least one
of them, such as C++, Java, or Python. There is a considerable chance that you may
be asked to write a code on pen and paper. Problem-solving skills will also be
checked by the interviewer.
Knowledge of the most recent technological developments is an added advantage.
You should have a fundamental awareness of contemporary technology trends, such
as artificial intelligence (AI), big data, and so on. You'll be asked questions about your
previous projects and job experiences, such as what you did, what technology you
utilized, what you developed, and how successful you were, among other things.
Questions related to CV and company may also be asked.
A er clearing the technical interview round, the candidates are called for HR
ROUND.
ROUND 3: HR Interview

Page 7 © Copyright by Interviewbit


Cognizant Interview Questions

This is the most important round of the interview process. During this round, many
in-tenders are rejected. The goal is to maintain a pleasant and confident demeanor.
Interviews can be long and tedious, so remember to smile!
During the HR phase, the interview panel will ask you questions about your
personality, family background, education, interests, internships, work experience (if
applicable), and other topics. Make preparations to answer questions on internships,
projects, volunteerism, and extracurricular activities mentioned in your CV. There can
be questions related to the company - what are the products/services the company
offers, what are its core values, when it was formed, its organizational structure, and
so on.
You can never be too prepared when it comes to HR interview questions and
responses. The greatest thing you can do is develop a list of the most popular HR
interview questions and practice answering them. You should have the answers to
these questions at your fingertips. Another crucial thing to keep in mind while going
for an interview is to look and behave confidently. Keep in mind that you should not
lie or be overconfident. Having excellent body language can make all the difference.
Cognizant Company HR interview questions For Freshers and Experienced-

Page 8 © Copyright by Interviewbit


Cognizant Interview Questions

Tell me something about yourself. (Start with your academics, projects,


achievements, other curriculum activities, and your strengths if you are a
beginner. Also, tell them about your hobbies, background, and so on. If you're an
experienced professional, start with your present position, achievements,
previous work history, and then academic and personal information.)
Are you willing to relocate to different parts of India?
What are your strengths?
Why should we hire you?
What are some of the characteristics of this profession that you enjoy?
Describe your Final Year Project. What new ideas did you bring to the table for
this project?
Why are you looking for a job change? (If you're an experienced professional
seeking a change, this is a common question. The easiest method to respond to
this question is to state that you are leaving your current work in order to
advance your career. Make sure you don't criticize or speak poorly about the
company where you now work.)
What is your expected salary? (This is a difficult question to answer. It is
generally asked from experienced employees. You may inquire about the
company's standard raise for employees.)

Cognizant Technical Interview Questions: Freshers


and Experienced
3. Write the code to find the length of a string without using the
string functions.

Page 9 © Copyright by Interviewbit


Cognizant Interview Questions

#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;
}

4. How will you print the address of a variable without using a


pointer?
We may acquire the address of any variable by using the “address of operator” (&)
operator, which yields 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;
}

5. What do you understand about Proactive, Retroactive and


Simultaneous Update in the context of DBMS?

Page 10 © Copyright by Interviewbit


Cognizant Interview Questions

Proactive Updates: These changes are made to the database before it is put
into use in the real-world environment.
Retroactive Updates: These updates are applied to a database a er it has been
operational in the real-world environment.
Simultaneous Updates: These updates are applied to the database at the same
moment as they become functional in the real-world environment.

6. List out the differences between Generalization and


Specialization in DBMS.

Page 11 © Copyright by Interviewbit


Cognizant Interview Questions

GENERALIZATION SPECIALIZATION

Generalization uses a Specialization uses a top-


Bottom-Up approach. down approach.

The size of the schema gets The size of the schema gets
reduced in Generalization. increased in Specialization.

Generalization is usually Specialization can be


applied to a group of entities. applied to a single entity.

The practice of forming The process of forming


groupings from diverse entity subgroups inside an entity
sets is known as set is known as
Generalization. Specialization.

In Generalization, in order to
form a higher entity, the
In Specialization, lower
differences and similarities
entities are formed by
between lower entities are
splitting higher entities.
ignored and their union is
considered.

Inheritance does not exist in Inheritance exists in


Generalization. Specialization.

Page 12 © Copyright by Interviewbit


Cognizant Interview Questions

7. What is the fill factor in SQL? What is its default value?


The fill factor is the percentage of space on each leaf-level page that will be filled with
data. The smallest unit in SQL Server is a page, which is made up of 8K pages.
Depending on the size of the row, each page can store one or more rows. The Fill
Factor's default value is 100, which is the same as the value 0. The SQL Server will fill
the leaf-level pages of an index with the highest number of rows it can fit if the Fill
Factor is set to 100 or 0. When the fill factor is 100, the page will have no or very little
vacant space.

8. What exactly is index hunting, and how does it aid query


performance?
Index hunting is the method of boosting a collection of indexes. This is done because
indexes improve query performance as well as query processing time.
It aids in query performance improvement in the following ways:
Using the query optimizer, the optimal queries are suggested.
To check the effect, parameters such as index, query distribution, and
performance are used.
Databases are optimized into a small group of problem queries.

9. Write the steps to create, update and drop a view in SQL.


In SQL, a view is a single table that contains data from other tables. As a result, a view
features rows and columns that are identical to those of a real table, as well as fields
from one or more tables.
In order to create a view:

CREATE VIEW View_Name AS


SELECT Column1, Column2, Column3, ..., ColumnN
FROM Table_Name
WHERE Condition;

For updating a view:

Page 13 © Copyright by Interviewbit


Cognizant Interview Questions

CREATE VIEW OR REPLACE View_Name AS


SELECT Column1, Column2, Column3, ..., ColumnN
FROM Table_Name
WHERE Condition;

For dropping a view:

DROP VIEW View_Name;

In the above queries, Column1, Column2, .. ColumnN denotes the name of the
columns to be added or updated. View_Name denotes the name of the view created
and Table_name denotes the name of the current table.

10. What are the similarities and the differences between


Shortest Job FIrst (SJF) and Shortest Remaining TIme FIrst
(SRTF) CPU scheduling algorithms?
SJF (Shortest Job First) is a scheduling policy that prioritizes the waiting process with
the shortest execution time. Shortest Job Next (SJN) or Shortest Process Next are
other names for it (SPN). It is a scheduling algorithm that is not preemptive (that is,
one process cannot snatch the resources assigned to a currently running process).
The preemptive variant of SJF scheduling is the Shortest Remaining Time First
(SRTF). The procedure, next in the queue, with the least amount of time till
completion is chosen to be executed in this scheduling technique. Processes that
arrive at the same time transform SRTF to SJF.
Similarities:
Both SJF and SRTF are essentially difficult to implement since the processes'
burst time cannot be predicted.
Both SJF and SRTF have the potential to cause process starvation since long
processes can be delayed forever if short processes are constantly added.
Once all of the processes are in the ready queue, both SJF and SRTF are
regarded the same. This is because no preemption is performed a er the
processes are added to the ready queue.

Page 14 © Copyright by Interviewbit


Cognizant Interview Questions

Shortest Job First Shortest Remaining Time First

SJF is a non-preemptive
SRTF is a preemptive algorithm.
algorithm.

SJF involves less SRTF involves more overhead


overheads than SRTF. than SJF.

SJF results in
SRTF results in increased
comparatively lower
throughput as execution is faster.
throughput.

SJF reduces the average SRTF may or may not reduce the
waiting time for each average waiting time for each
process. process.

SJF involves a lesser


SRTF involves a greater number
number of context
of context switching.
switching.

11. What factors influence whether or not a detection algorithm


is required in a deadlock avoidance system?
One of the factors is that it is dependent on how frequently a deadlock is likely to
occur when this algorithm is implemented. The other is the number of processes that
will be affected by deadlock if this algorithm is used.

12. How does Dynamic Loading help in better memory space


utilization?

Page 15 © Copyright by Interviewbit


Cognizant Interview Questions

In dynamic loading, a routine is not loaded until it is called. This strategy is very
effective when dealing with vast quantities of code, such as error routines, that occur
infrequently. All routines are saved in a relocatable load format on the disk. The main
program is executed a er it has been loaded into memory. When a routine requires
to call another routine, the calling routine checks to verify if the other routine is
loaded first. If this is not the case, the relocatable linking loader is used to load the
requested routine into memory and update the program's address tables. The newly
loaded routine is then given control. In this way, dynamic loading helps in better
memory space utilization.

13. What is Root Partition in OS?


The root partition is the place where the operating system kernel is located. Other
potentially crucial system files that are mounted during boot time are contained in it
as well.

14. What is the purpose of a Virtual File System (VFS)?


An abstract layer on top of a more concrete file system is a virtual file system (VFS) or
virtual filesystem switch.
The purpose of a VFS is to make it possible for client applications to access
various types of concrete file systems in a consistent manner. For example, a VFS
can be used to seamlessly access local and network storage devices without the
client device recognizing the difference.
It can be used to bridge the gap between Windows, traditional Mac OS/macOS,
and Unix filesystems, allowing applications to access files on those sorts of local
file systems without needing to know what type of file system they're dealing
with.
A VFS defines the kernel's interface with a certain file system. As a result, adding
support for new file system types to the kernel is simple.

15. What is caching? How does caching work?

Page 16 © Copyright by Interviewbit


Cognizant Interview Questions

Caching is a technique for saving numerous copies of the most frequently used data
in a temporary storage area (or cache) so that they can be accessed more quickly. It
keeps data in a temporary format for so ware applications, servers, and web
browsers, so users don't have to download information every time they visit a
website or use an application.
Cached data works by saving data in a device's memory for later access. The data is
kept in the memory of a computer, directly below the central processing unit (CPU).
The primary cache level is incorporated into a device's microprocessor chip, followed
by two more secondary cache levels that feed the primary level. This information is
kept until the content's time to live (TTL), which specifies how long it should be
cached, expires or the device's disc or hard drive cache fills up.
Data is usually cached in one of two ways: browser or memory caching (data stored
locally on the computer) or Content Delivery Networks (data stored in geographically
distributed locations).

16. What is Preemptive Multitasking? How is it different from


Cooperative Multitasking?
Preemptive multitasking permits computer programs to share operating systems
(OS) and underlying hardware resources. It distributes the overall operating and
computing time amongst processes, and it uses established criteria to switch
resources between processes. Time-shared multitasking is another name for
preemptive multitasking.
The operating system never initiates context switching from one process to another
in cooperative multitasking. Only when the processes voluntarily cede control on a
routine basis, or when they are inactive or logically blocked, does a context switch
occur, allowing many applications to run at the same time. In addition, in this
multitasking, all processes work together to make the scheduling strategy work.

17. What is plumbing/piping in Linux or Unix?

Page 17 © Copyright by Interviewbit


Cognizant Interview Questions

Plumbing/ Piping refers to the technique of using one program's output as an input
to another. For instance, Instead of delivering a folder or drive listing to the main
screen, it can be piped and delivered to a file, or sent to the printer to print a hard
copy.
A pipe is a type of redirection (the transfer of standard output to another location)
used in Linux and other Unix-like operating systems to transport the output of one
command/program/process to another for additional processing. The Unix/Linux
systems allow a command's stdout to be connected to another command's stdin.
The pipe character ‘|' can be used to do this.

18. Name the typical elements of a processed image.


The typical elements of a processed image are:
User data: This element of user space includes program data, user stack area,
and programs that can be modified.
User program: The set of instructions that are to be executed.
System Stack: Each process is associated with one or more LIFO (Last In First
Out) stacks. Parameters and calling addresses for procedure and system calls are
stored here.
Process control Block (PCB): Information required by the operating system to
control operations.

19. What is Trapdoor in OS?


A trapdoor is a so ware or hardware mechanism that can be used to bypass system
controls. In general, it's malicious so ware that allows an attacker on the other side
of the Internet to gain unauthorized access to a computer system or network by
accepting remote commands. Trap door so ware monitors a specific Transmission
Control Protocol (TCP) or User Datagram Protocol (UDP) port for orders.

20. What is the Translation Lookaside Buffer?

Page 18 © Copyright by Interviewbit


Cognizant Interview Questions

Translation TLB (Transaction Look-aside Buffer) is a particular cache that keeps track
of recently used transactions. The TLB includes the most recently used page table
entries. The CPU analyses the TLB when given a virtual address. The frame number is
retrieved and the real address is created if a page table entry (TLB hit) is present. If a
page table entry is missing from the TLB (TLB miss), the page number is used as an
index while processing the page table. The TLB first checks if the page is already in
main memory; if it isn't, a page fault is generated, and the TLB is then modified to
incorporate the new page entry.

21. What is the resident set and working set?


At any given time, the resident set is the part of the processed image that is actually
in the real memory. It's broken down into subsets, one of which is the working set.
The working set is the subset of the resident set required for execution.

22. List the differences between RSA (Rivest, Shamir, Adleman)


and Digital Signature Algorithm (DSA).

Page 19 © Copyright by Interviewbit


Cognizant Interview Questions

RSA DSA

DSA is a digital signature


RSA is a cryptosystem algorithm.
algorithm.

This algorithm finds its


This algorithm finds its
application in digital
application in secure data
signature and its
transmission.
verification.

It implements the mathematical It implements the


concept of factorization of the concept of modular
product of two large prime exponentiation and
numbers. discrete logarithm.

DSA is faster in key


RSA is slower in key generation as
generation as compared
compared to DSA.
to RSA.

DSA is slower in
RSA is faster in encryption but
encryption but faster in
slower in decryption as
decryption as compared
compared to DSA.
to RSA.

23. What is a bridge router (als known as brouter) ?


A bridge router, sometimes known as a brouter, is a network device that can function
as both a bridge and a router. The brouter forwards all other packets like a bridge and
only routes packets for known protocols.

Page 20 © Copyright by Interviewbit


Cognizant Interview Questions

For routable protocols, brouters function at the network layer, while for non-routable
protocols, they operate at the data link layer. Brouters operate as routers for
routable protocols and bridges for non-routable protocols, handling both routable
and non-routable characteristics. Brouters are connecting devices in networking
systems that serve as both a network bridge and a router in the internetwork.

24. What is Exterior Gateway Protocol (EGP)?


The Exterior Gateway Protocol (EGP) is a protocol that allows Internet gateways from
the same or separate autonomous systems to share network reach-ability
information.
EGP serves three primary purposes:
Create a set of neighbors.
Keep a check on the neighbors (to see if they are still alive and reachable).
Notify the neighbors about the networks that are accessible from their
autonomous systems.

25. What do you know about Network Virtual Terminal (NVT)?


Rather than communicating in native "languages", all Telnet clients and servers agree
to deliver data and commands that conform to a fictional "virtual" terminal type
known as the Network Virtual Terminal (NVT). The NVT specifies a set of standards for
formatting and sending data, including character set, line termination, and how
information about the Telnet session is provided.
Every Telnet client on a terminal can communicate in both its native language and
NVT. When a user enters information on his or her local terminal, it is translated to
NVT and sent over the network in that format. When the Telnet server receives this
information, it converts it from NVT to the format required by the remote host. In
reverse, the same procedure is followed for transmissions from the server to the
client.

26. What is the Hamming Code?

Page 21 © Copyright by Interviewbit


Cognizant Interview Questions

The Hamming code is a set of error-correction codes that can be used to detect and
fix errors that can arise when data is transferred or stored from one source to
another. Redundant bits are extra binary bits that are created and added to the data
transfer's information-carrying bits to ensure that no bits are lost during the data
transfer. A parity bit is a bit that is appended to binary data to verify that the total
number of 1s is even or odd. Error detection is done with parity bits. The Hamming
Code is essentially the use of additional parity bits to allow for error detection.

27. What is the purpose of a Pseudo TTY (pseudo terminals)?


A bidirectional communication channel is provided by a pair of virtual character
devices known as a pseudo TTY (or "PTY"). The master is at one end of the channel,
while the slave is at the other. The pseudo-terminal's slave end provides an interface
that is identical to that of a conventional terminal. A process that expects to be
connected to a terminal can open the slave end of a pseudo-terminal, which will
subsequently be controlled by a program that has opened the master end. Anything
written on the master end is supplied to the slave end's process as if it were any input
entered on a terminal. Anything written to the slave end of the pseudo-terminal, on
the other hand, can be read by the process linked to the master end. Network login
services, terminal emulators, and other such applications employ pseudo-terminals.

28. What is BufferedWriter? What are flush() and close() used


for?
BufferedWriter is a temporary data storage source. It's used to make a buffered
character output stream with the default output buffer size.
To flush characters from the buffered writer stream to a file, the flush() function of
the BufferedWriter class in Java is employed. It ensures that all data items, including
the last character, are written to the file.
The close() function of the Java BufferedWriter class flushes the characters from the
buffer stream and then closes it. Calling methods like write() and append() a er the
stream has been closed will generate an error.

Page 22 © Copyright by Interviewbit


Cognizant Interview Questions

29. What is stored in each of the memory structures- stack and


heap, and how are they related to each other?
The stack is a section of memory that stores information about nested method
(recursive) calls all the way down to the present program location. It also holds all
local variables and heap references defined in the currently running procedures. This
structure enables the runtime to return from the method knowing the address from
which it was invoked, as well as to remove all local variables when the procedure has
been exited. Every thread has a stack of its own.
The heap is a big chunk of memory used for dynamic allocation. When you use the
new keyword to create an object, it is allocated on the heap. The reference to this
object, on the other hand, is stored on the stack.

30. Is it possible to «resurrect» an object that has become


eligible for garbage collection in Java?
The Garbage Collector (GC) must call the finalize method on an object when it
becomes garbage collection eligible. Because the finalize method can only be used
once, the GC marks the object as finalized and sets it aside until the next cycle.

Page 23 © Copyright by Interviewbit


Cognizant Interview Questions

You can technically "resurrect" an object in the finalize method by assigning it to a


static field, for example. The object would revive and become ineligible for garbage
collection, preventing the GC from collecting it in the next cycle.
The object, on the other hand, would be marked as finalized, thus the finalize
method would not be invoked when it became eligible again. In essence, you can
only use this "resurrection" method only once.
Example:

Page 24 © Copyright by Interviewbit


Cognizant Interview Questions

// Java Program to illustrate Object Resurrection

import java.io.*;
import java.util.*;

public class InterviewBit {

private int num;

// Constructor
public InterviewBit(int num)
{

// assigning the parameter value to the member variable


this.num = num;
}

// Creating an ArrayList of class object


static final ArrayList<InterviewBit> ar = new ArrayList<InterviewBit>();

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 InterviewBit(i));
for (int j = 0; j < 5; j++) {

// printing the element in the object


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);
}
}
}

Page 25 © Copyright by Interviewbit


Cognizant Interview Questions

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 finalize method adds the items to the collection once and then resurrects them.
They have been marked as finalized and will not be queued again when they are
collected a second time.

31. Is it possible to override and overload a static method in


Java? Is it possible to override a private method in Java?
Because static methods are resolved at compile time, one cannot override them in
Java. Because objects are only available at runtime, overriding requires a virtual
method that is resolved at runtime. In Java, a static method can be overloaded.
Overloading has nothing to do with runtime, but each method's signature must be
distinct. To alter the method signature in Java, either the number of parameters, the
type of arguments, or the sequence of arguments must be changed.
In Java, you can't override a private method because the subclass doesn't inherit the
private method, which is required for overriding. In fact, no one outside the class can
see a private method, and a call to it is handled at compile time using Type
information rather than at runtime using the actual object.

32. What is monkey patch in Python?


Monkey patches are dynamic (or run-time) alterations of a class or module in Python.
We can truly change the behavior of code at runtime in Python.
Example:

Page 26 © Copyright by Interviewbit


Cognizant Interview Questions

# m.py
class A:
def func(self):
print ("func() is called")

In the code below, we use the above module (m) to change the behavior of func() at
runtime by assigning a new value.

import m
def monkey_func(self):
print ("monkey_func() is called")

# replacing the address of "func" with "monkey_func"


m.A.func = monkey_func
ob = m.A()

# calling the function "func"


ob.func()

Output:

monkey_func() is called

Explanation:
We have assigned the monkey_func to the address of “func” of class A. Thus, when
we call the “func” function of “ob”, the monkey function is called.

33. Write the code to add two numbers without using arithmetic
operators.
The sum of two bits can be found by executing an XOR (^) operation on the two bits. A
carry bit can be obtained by performing AND (&) on the two bits.
The logic shown below is a simple Half Adder that may be used to add two single bits.
This logic can be extended to integers. If there are no set bits at the same position(s)
in a and b, bitwise XOR (^) of a and b yields the sum of a and b. Bitwise AND (&) is used
to include common set bits as well. All carry bits are obtained by bitwise AND of a and
b. To acquire the needed result, we compute (a & b) << 1 and add it to a ^ b.

Page 27 © Copyright by Interviewbit


Cognizant Interview Questions

// C Program for adding two numbers


// without the use of arithmetic operators
#include<stdio.h>

int Addition(int a, int b)


{
// Iterate until no carry
while (b != 0)
{
// carry now stores common
//set bits of a and b
unsigned carry = a & b;

a = a ^ b;

// Carry to be shifted by one so that on adding


// it to a, we get the required sum
b = carry << 1;
}
return a;
}

34. Write a code to print numbers from 0 to 100 in C++ without


using loop and recursion.
Template Metaprogramming is the idea used in this code.
Let's have a look at how this works. Non-data types can also be used as parameters in
C++ templates. The term "non-datatype" refers to a value rather than a datatype. In
the preceding code, for example, N is passed as a value rather than a datatype. For
each parameter, a new instance of a generic class is constructed, and these classes
are created at compile time.

Page 28 © Copyright by Interviewbit


Cognizant Interview Questions

#include <iostream>
using namespace std;

template<int n>
class PrintZeroToN
{
public:
static void display()
{
PrintZeroToN<n-1>::display(); // this should not be mistaken for recursion
cout << n << endl;
}
};

template<>
class PrintZeroToN<0>
{
public:
static void display()
{
cout << 0 << endl;
}
};
int main()
{
const int n = 100;
PrintZeroToN<n>::display();
return 0;
}

Explanation:
N is passed as a value rather than a data type in the above program. For each
parameter, a new instance of a generic class is constructed, and these classes are
created at compile time. When the compiler encounters the line
“PrintZeroToN<>::print()” with N = 100, it produces an instance PrintZeroToN<100>.
Another function PrintZeroToN<99>::print() is called in function
PrintZeroToN<100>::print(), resulting in the creation of an instance
PrintZeroToN<99>. All instances from PrintZeroToN<100> to PrintZeroToN<1> are
created in the same way. The function PrintZeroToN<0>::print() already exists and
prints 0. The PrintZeroToN<1> function prints 1 and so on. As a result, all numbers
from 0 to N are printed on the screen.

Page 29 © Copyright by Interviewbit


Cognizant Interview Questions

Cognizant Interview Preparation


35. Interview Preparation Tips
Keep a positive attitude and a smile on your face at all times. If you are confident
enough, you have already completed half of the task.
Practice well. Just like any other exam or test, you can only pass them if you
have a thorough understanding of the material and have practiced at least 100
times before taking the actual tests. If you have any doubts about a subject,
make sure you clear them up by reading good books or enrolling in an
appropriate online course for aptitude preparation.
Make sure you brush up on your coding test papers, as well as practice
programming fundamentals, such as C, C++, Java, and other computer
fundamentals such as OOPs, concepts, database, and networking. Develop a
code to find the GCD of a number or write a code for bubble sort, for example.
It is important that you are familiar with your CV. Make sure that everything
you've stated on your CV about previous projects and internships is accurate and
that you know everything. You'll be asked questions about your previous
projects and job experiences, such as what you did, what technology you
utilized, what you developed, and how successful you were, among other things.
Visit the company’s website. Make sure you learn everything you can about
Cognizant, such as what kind of work/projects it is currently working on.
Employers expect you to understand who the company is, what it does, how it
fits into your career aspirations. These types of questions are generally asked in
the HR round.
Make sure you're up to date on the latest technical advancements. You should
have a fundamental understanding of current technology trends, such as
artificial intelligence (AI), big data, and so on.
Speak with assurance. It is more important to listen to the interviewer than to
respond. Before you attempt to answer a question, make sure you understand it
completely. If you don't understand something, don't be afraid to ask for an
explanation.

Frequently Asked Questions

Page 30 © Copyright by Interviewbit


Cognizant Interview Questions

36. Is cognizant interview difficult?


The amount of effort you put into preparing for an interview determines how difficult
it is. The more you prepare, the easier it will be to pass the interview. All you need to
know is the fundamentals of new technologies, programming languages, your
projects, and Cognizant. Interviewers are interested in how candidates approach
problems, construct their thought process, and display personal qualities such as
communication, in addition to technical knowledge (which is vital).

37. What is the fresher salary in Cognizant?


At Cognizant, a fresher's pay ranges from 3.3 to 4.5 lakhs.

38. What are the questions asked in a Cognizant interview?


Questions are asked related to a fundamental understanding of operating systems,
database management systems (RDBMS, various keys), computer networks
(particularly the OSI model and its seven layers of function, protocols, IP addresses,
routers, and so on), and cloud computing. Your programming abilities will also be
examined. Be prepared with the fundamentals of Java, HTML, C, C++ among other
topics. The interviewer might ask basic questions regarding the candidate's job
experience, expected salary, background, qualification during the HR Round. Learn
More.

39. Is there any bond in Cognizant?


There is no such thing as a Bond. In the sense that you are not required to pay any
money if you desire to terminate your contract with the firm.

40. Does cognizant have a dress code?


The dress code is casual. Simply maintain a neat and tidy appearance.

41. How can I apply for Cognizant ?


You can apply to Cognizant in a variety of ways, including through employment sites,
Cognizant's career page, attending recruiting drives, using the employee referral
system, or consulting with placement experts.

Page 31 © Copyright by Interviewbit


Cognizant Interview Questions

The Cognizant Recruitment Process consists of two steps:


Online exam
Interview process
Technical interview
HR interview
Check out the above section for the detailed interview process.

43. How is career growth in Cognizant?


Cognizant is proud of its workers' achievements and is committed to promoting their
personal and professional development by providing:
Well defined role enhancement programs
Career planning
Opportunities to advance their careers by pursuing further education or industry
credentials.
Possibilities to apply for open employment at Cognizant

Page 32 © Copyright by Interviewbit


Links to More Interview
Questions

C Interview Questions Php Interview Questions C Sharp Interview Questions

Web Api Interview Hibernate Interview Node Js Interview Questions


Questions Questions

Cpp Interview Questions Oops Interview Questions Devops Interview Questions

Machine Learning Interview Docker Interview Questions Mysql Interview Questions


Questions

Css Interview Questions Laravel Interview Questions Asp Net Interview Questions

Django Interview Questions Dot Net Interview Questions Kubernetes Interview


Questions

Operating System Interview React Native Interview Aws Interview Questions


Questions Questions

Git Interview Questions Java 8 Interview Questions Mongodb Interview


Questions

Dbms Interview Questions Spring Boot Interview Power Bi Interview Questions


Questions

Pl Sql Interview Questions Tableau Interview Linux Interview Questions


Questions

Ansible Interview Questions Java Interview Questions Jenkins Interview Questions

Page 33 © Copyright by Interviewbit

You might also like