Cognizant Technical Interview Questions

CTS Technical Interview Questions for Freshers

On this page, you will find the most updated information, and questions, for CTS Technical Interview Questions.

Most of the technical questions were asked from C, C++, software engineering, final year projects and so on.. for both IT and Non IT students.

Cognizant technical Interview questions

Process for CS-IT v/s Non-CS-IT

Cognizant Programmer Trainee Interview Experience

CS-IT Students

  • C Theory/Programs, JAVA and C++
  • OOPS
  • Software Engineering
  • Final year Project
  • Optional – DBMS, Operating Systems, Data Structures

Cognizant Programmer Trainee Interview Preparation

Non-CS-IT Students

  • Basic C Theory/Programs
  • C++ or Java
  • OOPS
  • Final Year Project
  • Optional Topic

Top Cognizant Interview Technical Interview Questions

Question 1: What is a pointer?

Answer:

A variable that stores the address of another variable is called a pointer. The address of a normal variable, array variable, or another pointer variable is often kept during this pointer.

The benefits of employing a pointer include the following:

  • Allocation of dynamic memory
  • Handling arrays, strings, and structures in functions improves execution performance.
  • They play a vital role in OS design.

Question 2:- What do you mean by Inter-Process Communication?

Answer:

Inter-Process Communication (IPC) is the mechanism by which cooperating processes share data and information. There are 2 ways by which Inter process communication is achieved –

  • Shared Memory
  • Message Parsing

Question 3: What is a semaphore?

Answer:

Semaphore is also an entity devised by Edsger W. Dijkstra, to solve the Process Synchronization problem in OS. Its most popular use is in solving the Critical Section algorithm. It uses a signaling mechanism to allow access to shared resources namely by two – (A) Wait and (B) Signal.

Questions 4: What do you mean by a Deadlock?

Answer:

Deadlock refers to the condition when 2 or more processes are waiting for each other to release a resource indefinitely. A process in nature requests a resource first and uses it and finally releases it. But in a deadlock situation, both the processes wait for the other process.

Question 5: What is a dangling pointer?

Answer:

A dangling pointer is a pointer that still points to a memory address that has been removed.

Question 6: Write a program to reverse any number using C and C++.

Question 7: What is the difference between a stack and an array?

Answer:

Stack follows a LIFO pattern. It means that data access follows a sequence wherein the last data to be stored when the first one to be extracted.

Arrays, on the other hand, do not follow a particular order and instead can be accessed by referring to the indexed element within the array.

Question 8: What are deadlock prevention techniques?

Answer:

The way to prevent deadlock is to ensure that at least one of these conditions does not hold :

  • Mutual exclusion – If 1 resource is non-shareable, then the mutual exclusion condition must hold. We can’t prevent deadlock by denying this mutual exclusion condition, as some resources are inherently non-shareable and this can’t be changed.
  • Hold And wait – For the Hold and wait condition to never occur, it should be made sure that whenever a process requests a resource, it does not hold any other resource. There can be many protocols implemented –
    • One protocol could be allocating all resources to a process before its execution.
    • Other Could be, A process can request resources only when it has no resources.

Questions 9: What is recursion?

Answer:

Recursion is designed to solve problems that can be broken down into smaller, repeatable tasks. Because recursion involves repeatedly calling the same function, it has a short code length. It’s especially useful for dealing with problems that have a lot of potential branches but are too complicated for an iterative approach. In problems involving trees and graphs, recursion works best.

Question 10: Write a program to add two functions in Java

//Java program to add two fractions
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
//scanner class declaration
Scanner sc = new Scanner(System.in);
//input from the user
System.out.print("Enter numerator for first fraction : ");
int num1 = sc.nextInt();
System.out.print("Enter denominator for first fraction : ");
int den1 = sc.nextInt();
System.out.print("Enter numerator for second fraction : ");
int num2 = sc.nextInt();
System.out.print("Enter denominator for second fraction : ");
int den2 = sc.nextInt();
int num, den, x;
System.out.print("("+num1+" / "+den1+") + ("+num2+" / "+den2+") = ");
//logic for calculating sum of two fractions
if(den1 == den2)
{
num = num1 + num2 ;
den = den1 ;
}
else{
num = (num1*den2) + (num2*den1);
den = den1 * den2;
}
if(num > den)
x = num;
else
x = den;
for(int i = 1 ; i <= x ; i++)
{
if(num%i == 0 && den%i == 0)
{
num = num/i;
den = den/i;
}
}
//logic for getting simplified fraction
int n = 1;
int p = num;
int q = den;
if( num != den)
{
while(n != 0)
{
//storing remainder
n = num % den;
if(n != 0)
{
num = den;
den = n;
}
}
}
System.out.println("("+p/den+" / "+q/den+")");
//closing scanner class(not compulsory, but good practice)
sc.close();
}
}

Question 11: What is a Binary Tree?

Answer:

A binary tree is one type of data structure that has two nodes, a left node, and a right node. In programming, binary trees are an extension of the linked list structures.

Question 12: What is printf?

Answer:

“printf” stands for “print formatted” and is the name of one of the main C output functions. Scanf format strings provide formatted input, while printf format strings provide unformatted input. Printf is used to print integers, characters, floats, and strings. 

Question 13: What is the size of the float data type?

Answer:

The size of the float data type is 4bytes

Question 14: Define software engineering.

Answer:

Software engineering is made up of two terms that is software and engineering.

  • Software refers to the set of instructions that tells a computer what to do and how to perform any tasks.
  • Engineering is the work to build and design something in an effective manner.

Software engineering is an engineering branch to develops a software product using some scientific principles and procedures. The result will be a reliable and good quality product.

Question 15: What are the Advantages and Disadvantages of white box testing?

Answer:

Advantages:

  • Entire code and structures are tested in the white box testing.
  • It results in the optimization of code removing errors and helps in removing extra lines of code.
  • This testing can start at an earlier stage.
  • White box testing is easy to automate.

Disadvantages:

  • This testing is very expensive and time-consuming.
  • Redesign of code needs test cases to be written again.
  • Missing functionalities cannot be detected.
  • This technique can be very complex and at times, not realistic.

Question 16: What is SDLC?

Answer:

SDLC stands for Software Development Life Cycle. There are various software development models which are used in the software development life cycle to represent the process of building software. SDLC models define all the phases of software development.
SDLC models can have a different methodology but the phases remain the same. The development team chooses the best SDLC model to develop a software product so that an efficient and reliable software product is developed. By using SDLC models, you can develop a software product in a systematic and nice way.
Here are some important SDLC models are given below-

  • Waterfall Model
  • Iterative Waterfall Model
  • Agile Model
  • Spiral Model
  • Prototype Model
  • V model
  • RAD model

Question 17: Can we use int datatype to store 32768 values?

Answer:

No, the Integer data type does not support the range -32768 to 32767. Any value greater than that would be discarded. We have the choice of using float or long int.

Question 18: Write a program to find the roots of a quadratic equation.

Question 19: What are the different types of normalization?

Answer:

Normalization is a  step-by-step process via which we reduce the complexity of a database. The database may have a lot of redundancies (unnecessary information that has become outdated or no longer useful) like attendance records for former students in a university. Four major types of normalizations are 

  • First Normal Form (1NF): A relation is said to be in 1NF if and only if it does not have any multivalued attributes. Example: A Student table containing a Phone number column must contain only one phone number (value). After 1NF, we can still have redundant data.
  • Second Normal Form (2NF): A relation is said to be in 2NF if and only if it is in 1NF and NO Non-Prime attribute should be dependent on any Candidate key element, which is called not having a partial dependency. After 2NF, we can still have redundant data.
  • Third Normal Form (3NF): A relation is said to be in 3NF, if and only if it is in 2NF and there should not be any transitive dependency for non-prime attributes.
  • Boyce-Codd Normal Form(BCNF): A relation is said to be in BCNF, if and only if it is in 3NF and every non-trivial function dependency A -> B is a super key. In simple words, LHS should always be a super key.

Question 20: What is process synchronization?

Answer:

When several threads (or processes) share data, running in parallel on different cores, then changes made by one process may override changes made by another process running parallel, resulting in inconsistent data. So, this requires processes to be synchronized, and handling system resources and processes to avoid such a situation is known as Process Synchronization.

Question 21: What are the major differences between C++ and Java?

C++JAVA
The procedural and object-oriented programming languages are both supported by C++.Only object-oriented programming models must be supported by Java.
Memory management is done manually in C++.Memory management in Java is managed by the operating system.
C++ is a compiled language that cannot be interpreted.Java can be compiled as well as interpreted.
Global and namespace scopes are supported in C++.Global scope is not supported in Java.

Question 22:- What are the different types of SQL commands?

Answer:

SQL commands are broadly classified into 4 categories. They are –

  • DDL (Data Definition Language): DDL is used to define the structure of the database or the schema.  CREATE, ALTER, DROP, and TRUNCATE table are a few of the DDL commands used.
  • DML (Data Manipulation Language): DML is used for the manipulation of the data. In other words, DML statements are used for data management. Examples include INSERT, DELETE, and UPDATE. 
  • DQL (Data Query Language): DML statements are used to perform queries on the existing Database. Ex: SELECT statement.
  • DCL (Data Control Language): DCL is used to control the access to data that is stored in the Database. Example – GRANT and REVOKE. They provide access permissions to different kinds of users to access data in the database based on privileges(Like admin or a normal user or a super user).

Question 23:- What is overloading and overriding?

Answer:

Overloading: Function overloading is a concept in which two or more functions with the same name are defined in the same class with the condition that their parameters differ in number or type.

Overriding: Function overriding is a concept in which two functions with the same name and parameters are defined, with the requirement that one function is in a base class and the other in a derived class.

Question 24:- What is an Alternate Key?

Answer:

When a primary key is chosen from the set of candidate keys, the remaining keys are known as Alternate Keys.

Question 25:- What is an object?

Answer:

The object is a class instance that holds the memory required for the logic in the class.

Question 26:-What is RDBMS?

Answer:

RDBMS stands for Relational Database Management system. RDBMS was introduced by E. F. Codd. It is a software system or collection of various programs that work together on a relational data model database and offers various integrated entities like – Database administration, Data definition, creation, updation, etc. Some examples of RDBMS are –

  • SQL
  • MySQL
  • IBM DB2
  • Oracle
  • Microsoft Access

Question 27:- What is the friend function?

Answer:

A friend function can access the private/protected data of a class in which it is declared as a friend, even if it is a nonmember function of that class.

Question 28:- What are doubly-linked Lists?

Answer:

Doubly linked lists are a special type of linked list wherein traversal across the data elements can be done in both directions. This is made possible by having two links in every node, one that links to the next node and another one that connects to the previous node.

Question 29:- What is the Waterfall model?

Answer:

Waterfall Model – This is the first software development model. The waterfall model is the linear sequential model in which all the phases work in a sequential manner. The output of the previous phase is the input for the upcoming phase. But we cannot go back to the prior stage to change requirements. There is no overlapping between the phases of software development. This model takes less time to develop and is very easy to understand.

Question 30:- What are the various types of software maintenance?

Answer:

There are basically 4 types of software maintenance. They are

  • Corrective Maintenance: To correct any type of error present in the software product, corrective maintenance is used.
  • Adaptive Maintenance: As new technology emerges, the software is updated by taking up adaptive maintenance.
  • Perfective Maintenance: The object of perfective maintenance is to improve software reliability and performance and add some new things to software products.
  • Preventive Maintenance: There is a need for updation to prevent or correction of future errors in the software.

Question 31:- What is an Operating System?

Answer:

The connecting interface between the hardware of the computer and the end-user or his actions is called an operating system. The operating system carries out tasks asked to implement by the end-user, or supporting tasks to provide the functionality to the end-user with the help of computation power and support provided by the hardware of the system.

Question 32:- What are the 5 states in a process life cycle?

Answer:

A process can be in any of the following 5 states: 

  • New State
  • Ready State
  • Running State
  • Waiting State
  • Terminated State.

Question 33:- What are the different types of process scheduling in an Operating System?

Answer:

We divide Process Scheduling into the following two types: 

  • Preemptive Scheduling –The scheduling in which a running process can be interrupted if a high-priority process enters the queue and is allocated to the CPU is called preemptive scheduling. In this case, the current process switches from the running queue to the ready queue and the high-priority process utilizes the CPU cycle.
  • Non-Preemptive Scheduling – The scheduling in which a running process cannot be interrupted by any other process is called non-preemptive scheduling. Any other process which enters the queue has to wait until the current process finishes its CPU cycle. 

Question 34:- What are the different types of schedulers?

Answer:

There are three types of schedulers categorically –

  • Long-term Scheduler: Also knowns as Job Scheduler. It selects the process that is to be placed in the ready queue. The long-term scheduler basically decides the priority in which processes must be placed in the main memory. Processes of the long-term scheduler are placed in the ready state because in this state the process is ready to execute waiting for calls of execution from the CPU which takes time that’s why this is known as a long-term scheduler.
  • Short-term Scheduler: It decides the priority in which processes in the ready queue are allocated the central processing unit (CPU) time for their execution. The short-term scheduler is also referred to as the central processing unit (CPU) scheduler.
  • Medium-term Scheduler: Also knowns as CPU Scheduler. It places the blocked and suspended processes in the secondary memory of a computer system. The task of moving from main memory to secondary memory is called swapping out. The task of moving back a swapped-out process from secondary memory to main memory is known as swapping in. The swapping of processes is performed to ensure the best utilization of the main memory.

2 comments on “Cognizant Technical Interview Questions”


    • Chirag

      see my technical interview in cognizant was very good. Interviewer asks questions related to oops,and then i was asked to sort my name and a program for polymorphism and some questions related to operators and my project.

      But in hr interview i was asked about the company, introduce yourself,are you willing to relocate but the main problem was last question in which hr interview asked me about artificial intelligence and there was some condition like i don’t have to take pause…if a minor pause is there then my interview will end at that point only….and frankly speaking after 6,7 seconds i have minor pause and then he directly told me that I’m done with you….my hr interview lasted for about 3 mintues that’s it….i found interviewer a bit rude……