
Cognizant


Cognizant Junior Software Engineer Interview Questions and Answers for Freshers
Q1. If there are 10 ball 2 red, 5 blue ,3 orange and one ball is picked randomly what is probability that the ball picked is red?
What is the probability of picking a red ball out of 10 balls with 2 red, 5 blue, and 3 orange?
There are 2 red balls out of 10 total balls
The probability of picking a red ball is 2/10 or 1/5
The probability can also be expressed as 20%
Q2. Difference between abstract class & functional interface
Abstract class can have both abstract and non-abstract methods, while functional interface can have only one abstract method.
Abstract class can have constructors, fields, and methods, while functional interface can only have one abstract method.
Abstract class can have abstract and non-abstract methods, while functional interface can only have one abstract method.
Abstract class can provide default implementations for methods, while functional interface cannot.
Example: Abstract...read more
Q3. How to reverse an array of numbers?
To reverse an array of numbers, iterate through the array and swap elements from start to end.
Iterate through the array using two pointers, one starting from the beginning and the other from the end.
Swap elements at the two pointers and move the pointers towards the center until they meet.
Example: Input array [1, 2, 3, 4, 5], after reversing becomes [5, 4, 3, 2, 1].
Q4. Define internal working of Hashmap
Hashmap is a data structure that stores key-value pairs and uses hashing to quickly retrieve values based on keys.
Hashmap uses an array to store key-value pairs.
Keys are hashed to determine the index where the value will be stored.
Collision handling techniques like chaining or open addressing are used to deal with multiple keys hashing to the same index.
Retrieving a value involves hashing the key to find the index and then accessing the value stored at that index.
Example: Has...read more
Q5. Define multi threading & synchronisation
Multithreading is the ability of a CPU to execute multiple threads concurrently, while synchronization is the coordination of multiple threads to ensure data consistency.
Multithreading allows multiple threads to run concurrently on a single CPU core.
Synchronization is used to coordinate access to shared resources among multiple threads.
Examples of synchronization mechanisms include locks, semaphores, and monitors.
Multithreading can improve performance by utilizing idle CPU ti...read more
Q6. What are data types?
Data types are classifications of data items that determine the possible values and operations that can be performed on them.
Data types define the type of data that a variable can hold, such as integers, strings, or booleans.
Examples of data types include int (integer), float (floating point number), char (character), and bool (boolean).
Data types also determine the size of the variable in memory and the range of values it can store.
Q7. Define the Oops pillars.
Oops pillars are the four main principles of object-oriented programming: Inheritance, Encapsulation, Abstraction, and Polymorphism.
Inheritance: Allows a class to inherit properties and behavior from another class.
Encapsulation: Bundling data and methods that operate on the data into a single unit.
Abstraction: Hiding the complex implementation details and showing only the necessary features of an object.
Polymorphism: Ability of an object to take on many forms.
More about working at Cognizant







Top HR Questions asked in Cognizant Junior Software Engineer for Freshers
Interview Process at Cognizant Junior Software Engineer for Freshers

Top Junior Software Engineer Interview Questions from Similar Companies



Reviews
Interviews
Salaries
Users/Month

