
Cognizant


20+ Cognizant Trainee Programmer Interview Questions and Answers
Q1. Networking Questions like What is IP ADDRESS WHAT IS MAC ADDRESS WHAT IS BSOD WHAT IS ACTIVE DIRECTORY WHAT IS NODE WHAT IS LAN WAN MAN WHAT IS SQL WHAT ARE SUBGROUPS OF SQL WHAT IS DML ,DDL TCL DCL? WHAT IS DB...
read moreAnswers to common networking and database related questions for a Trainee Programmer interview.
IP ADDRESS - unique identifier for devices on a network
MAC ADDRESS - unique identifier for network interface controllers
BSOD - Blue Screen of Death, an error screen displayed on Windows systems
ACTIVE DIRECTORY - centralized database for managing network resources
NODE - a device or computer on a network
LAN WAN MAN - types of networks (Local Area Network, Wide Area Network, Metropolit...read more
Q2. what is polymorphism in Object-Oriented Programming?
Polymorphism is the ability of an object to take on many forms.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
It enables methods to be defined in the superclass and overridden in the subclasses.
Polymorphism helps in achieving code reusability and flexibility in object-oriented programming.
Example: A superclass 'Animal' with subclasses 'Dog' and 'Cat'. Both 'Dog' and 'Cat' can be treated as 'Animal'.
Q3. Rate yourself in 5 different programming languages on a 1-10 scale, 10 being the best.
I rate myself differently in different languages based on my experience and proficiency.
Java - 8: I have worked on multiple projects using Java and have a good understanding of its concepts.
Python - 7: I have used Python for scripting and automation tasks and have a decent understanding of its libraries.
C++ - 6: I have basic knowledge of C++ and have implemented some algorithms using it.
JavaScript - 8: I have worked on web development projects using JavaScript and its framewo...read more
Q4. Write a program using any language of your choice (It was a palindrome-based program.)
A program to check if a given string is a palindrome or not.
Take input string from user
Reverse the string
Compare the reversed string with the original string
If both are same, then the string is a palindrome
Else, the string is not a palindrome
Q5. write a C program to find maximum and minimum of given 3 numbers
Program to find maximum and minimum of 3 numbers in C
Use if-else statements to compare the numbers
Initialize variables to store maximum and minimum values
Consider using arrays to store the numbers for easier comparison
Q6. What is database management system ?
A database management system is a software that manages and organizes data in a database.
DBMS is used to create, modify, and delete data in a database.
It provides a way to store and retrieve data efficiently.
Examples of DBMS include MySQL, Oracle, and Microsoft SQL Server.
Q7. What is encapsulation?
Encapsulation is the process of hiding implementation details and restricting access to an object's properties and methods.
Encapsulation helps in achieving data abstraction and information hiding.
It prevents unauthorized access to an object's internal state.
It allows for better control over the object's behavior.
Example: A bank account class with private variables for balance and account number.
Example: A car class with private variables for speed and engine temperature.
Q8. What is API?
API stands for Application Programming Interface. It is a set of protocols, routines, and tools for building software applications.
API allows different software applications to communicate with each other
It defines how software components should interact
APIs can be public or private
Examples of APIs include Google Maps API, Twitter API, and Facebook API
Q9. Why C is called middle level language?
C is called middle level language because it combines features of both high-level and low-level languages.
C allows low-level manipulation like memory management and bit manipulation.
C also supports high-level features like functions, data structures, and dynamic memory allocation.
C is closer to the hardware compared to high-level languages like Java or Python, but not as close as low-level languages like assembly.
C provides a good balance between performance and flexibility.
Q10. Write a program to print a matrix of 3 by 3.
Program to print a 3x3 matrix using nested loops.
Use nested loops to iterate through rows and columns of the matrix.
Initialize a 2D array with 3 rows and 3 columns to store the matrix elements.
Print the elements of the matrix using nested loops.
Q11. difference between while loop and for loop
While loop is used when the number of iterations is not known beforehand, while for loop is used when the number of iterations is known.
While loop checks the condition before executing the block of code, while for loop initializes, checks condition, and increments/decrements in one line.
For loop is used when the number of iterations is known, while loop is used when the number of iterations is not known.
Example: while loop - while(i < 5) { //code } for loop - for(int i=0; i<5...read more
Q12. tell me about functions in c
Functions in C are blocks of code that perform a specific task and can be called multiple times within a program.
Functions in C are defined using a return type, function name, parameters, and a body enclosed in curly braces.
Functions can be called multiple times within a program to perform the same task without rewriting the code.
Functions can return a value using the 'return' statement.
Functions can also be void, meaning they do not return a value.
Example: int add(int a, int...read more
Q13. what is a string in C.
A string in C is a sequence of characters stored as an array of characters terminated by a null character.
Strings in C are actually arrays of characters.
Strings are terminated by a null character '\0'.
Strings can be initialized using double quotes, e.g. char str[] = "Hello".
Q14. tell me the tech stack used
Our tech stack includes Java, Spring Boot, React, and MySQL.
Java
Spring Boot
React
MySQL
Q15. what is a primary key
A primary key is a unique identifier for each record in a database table.
Uniquely identifies each record in a table
Cannot contain null values
Can consist of one or multiple columns
Used to establish relationships between tables
Q16. Preferable Programing Languages.
Preferable programming languages depend on the project requirements and team expertise.
Consider the project requirements and choose a language that best fits them.
Consider the team's expertise and choose a language that they are comfortable with.
Popular languages include Java, Python, C++, JavaScript, and Ruby.
For web development, JavaScript and its frameworks like React and Angular are popular.
For data science, Python and R are popular.
For mobile app development, Java and Sw...read more
Q17. What is pointer What is inheritance?
A pointer is a variable that stores the memory address of another variable. Inheritance is a mechanism in object-oriented programming where a new class inherits properties and behaviors from an existing class.
Pointer is used to store memory address of a variable
Pointer can be dereferenced to access the value stored at that memory address
Example: int *ptr; ptr = # *ptr = 10; // num now has value 10
Inheritance allows a new class to inherit properties and behaviors from an exist...read more
Q18. difference between break and continue.
Break is used to exit a loop, while continue is used to skip the current iteration and move to the next one.
Break is used to terminate the loop and exit it completely.
Continue is used to skip the current iteration and move to the next one.
Example: for(int i=0; i<5; i++) { if(i==3) { break; } System.out.println(i); } // Output: 0 1 2
Example: for(int i=0; i<5; i++) { if(i==3) { continue; } System.out.println(i); } // Output: 0 1 2 4
Q19. Any programming language Data types
Programming languages have various data types such as integers, floats, strings, and booleans.
Data types define the type of data that can be stored in a variable.
Common data types include integers, floats, strings, and booleans.
Some programming languages also have more complex data types like arrays, structures, and classes.
Data types can affect the performance and memory usage of a program.
Examples of data types in different programming languages: int in C++, float in Python...read more
Q20. Create table syntax in DBMS
Creating a table in a DBMS
Use CREATE TABLE statement
Specify table name and column names with data types
Add constraints like primary key, foreign key, etc.
Example: CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), age INT)
Execute the statement to create the table
Q21. What is algorithm
An algorithm is a step-by-step procedure for solving a problem or accomplishing a task.
An algorithm is a set of instructions that are followed to solve a problem.
It is a sequence of well-defined steps that can be executed in a specific order.
Algorithms can be represented using flowcharts, pseudocode, or programming languages.
Examples of algorithms include sorting algorithms like bubble sort and searching algorithms like binary search.
Q22. Java is fully oops concept?
Java is a fully object-oriented programming language.
Java supports all four pillars of OOP: encapsulation, inheritance, polymorphism, and abstraction.
Classes and objects are fundamental concepts in Java.
Java allows for the creation of user-defined classes and objects.
Inheritance enables code reusability in Java.
Polymorphism allows objects to be treated as instances of their parent class.
Abstraction allows for hiding implementation details and showing only necessary features t...read more
Q23. explain the concepts of oops
OOPs stands for Object-Oriented Programming. It is a programming paradigm based on the concept of objects.
OOPs focuses on creating objects that contain data and methods to manipulate that data.
Encapsulation is the concept of bundling data and methods that operate on the data within a single unit, called an object.
Inheritance allows a class to inherit properties and behavior from another class.
Polymorphism allows objects to be treated as instances of their parent class, enabli...read more
Q24. write code for string reverse
Code to reverse a string using array of characters
Use two pointers, one at the beginning and one at the end of the string
Swap characters at the two pointers and move them towards the center until they meet
Example: Input 'hello' -> Output 'olleh'
More about working at Cognizant







Top HR Questions asked in Cognizant Trainee Programmer
Interview Process at Cognizant Trainee Programmer



Reviews
Interviews
Salaries
Users/Month

