Add office photos
Cognizant logo
Engaged Employer

Cognizant

Verified
3.7
based on 50.6k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Software Developer
Fresher
Experienced
Clear (2)

Cognizant Software Developer Interview Questions and Answers for Freshers

Updated 13 May 2024

Q1. Print Name and Age Problem Statement

Create a class named Person with a string variable 'name' and an integer variable 'age', such that these variables are not accessible outside the class. Implement a method t...read more

Ans.

Create a class Person with private variables name and age, and methods to set and get their values.

  • Create a class Person with private variables 'name' and 'age'.

  • Implement a method setValue to set the variables' values.

  • Implement a method getValue to print the variables' values.

  • Ensure the name is a non-empty string and the age is a non-negative integer.

  • Encapsulate the data and provide a clear interface for setting and getting the values.

Add your answer
right arrow

Q2. Encode the Message Problem Statement

Given a text message, your task is to return the Run-length Encoding of the given message.

Run-length encoding is a fast and simple method of encoding strings, representing ...read more

Ans.

Implement a function to encode a text message using run-length encoding.

  • Iterate through the message and count consecutive characters

  • Append the character and its count to the encoded message

  • Handle edge cases like single characters or empty message

Add your answer
right arrow

Q3. What is the difference between hashtable and hash map

Ans.

Hashtable is synchronized and does not allow null keys, while hashmap is not synchronized and allows one null key.

  • Hashtable is synchronized, while hashmap is not.

  • Hashtable does not allow null keys, while hashmap allows one null key.

  • Hashtable is thread-safe, while hashmap is not.

  • Hashtable is slower than hashmap.

  • Hashtable is part of the legacy collection classes, while hashmap is part of the Java Collections Framework.

Add your answer
right arrow

Q4. What is virtual function

Ans.

Virtual function is a function in base class that is overridden in derived class.

  • Virtual functions allow polymorphism in C++

  • They are declared using the virtual keyword

  • They are resolved at runtime based on the object type

  • Virtual functions can be overridden in derived classes

  • They are used to achieve runtime polymorphism

Add your answer
right arrow
Discover Cognizant interview dos and don'ts from real experiences

Q5. what is array how it is used

Ans.

An array is a data structure that stores a collection of elements of the same type in a contiguous memory location.

  • Arrays are used to store multiple values in a single variable.

  • Elements in an array are accessed by their index, starting from 0.

  • Example: string[] names = {"Alice", "Bob", "Charlie"};

  • Arrays can be used to efficiently store and retrieve data in programming.

  • Arrays can be multidimensional, allowing for more complex data structures.

Add your answer
right arrow

Q6. what is linklist

Ans.

A linked list is a data structure that consists of a sequence of elements where each element points to the next element in the sequence.

  • Each element in a linked list is called a node.

  • Nodes in a linked list are connected by pointers or references.

  • Linked lists can be singly linked (each node points to the next node) or doubly linked (each node points to the next and previous nodes).

Add your answer
right arrow

Q7. what is polymorphism

Ans.

Polymorphism is the ability of a function or method to behave differently based on the object it is acting upon.

  • Polymorphism allows objects of different classes to be treated as objects of a common superclass.

  • There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).

  • Example: Inheritance allows a child class to override a method from its parent class, exhibiting polymorphic behavior.

Add your answer
right arrow

More about working at Cognizant

Back
Awards Leaf
AmbitionBox Logo
Top Rated Mega Company - 2024
Awards Leaf
Awards Leaf
AmbitionBox Logo
Top Rated IT/ITES Company - 2024
Awards Leaf
HQ - Teaneck. New Jersey., United States (USA)
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Cognizant Software Developer for Freshers

based on 17 interviews
5 Interview rounds
Resume Shortlist Round
Aptitude Test Round
Coding Test Round
Technical Round
HR Round
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

Samsung Logo
3.9
 • 81 Interview Questions
View all
Recently Viewed
SALARIES
Small Industries Development Bank of India
DESIGNATION
INTERVIEWS
Patra Corporation
No Interviews
JOBS
Aswani Industries
No Jobs
INTERVIEWS
Tech Mahindra
No Interviews
SALARIES
Paragon Digital Services
SALARIES
Changepond Technologies
INTERVIEWS
Cognizant
No Interviews
REVIEWS
HGS
No Reviews
SALARIES
Cogniter Technologies
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter