Add office photos
Engaged Employer

Bounteous x Accolite

3.4
based on 823 Reviews
Filter interviews by

10+ Cognizant Interview Questions and Answers

Updated 20 Mar 2025
Popular Designations

Q1. Sync Api vs Async Api, Sync Microservice and Async microservice example

Ans.

Sync API waits for a response before continuing, while Async API allows the program to continue executing without waiting for a response.

  • Sync API is blocking and waits for a response before proceeding

  • Async API is non-blocking and allows the program to continue executing while waiting for a response

  • Sync microservice handles requests sequentially, while Async microservice can handle multiple requests concurrently

  • Example of Sync API: REST API that waits for a response before ret...read more

Add your answer

Q2. Write a REST api to fetch user details using userId.

Ans.

Create a REST api to fetch user details using userId

  • Create a GET endpoint /users/{userId} to fetch user details

  • Use userId as a parameter in the endpoint

  • Return user details in JSON format

  • Handle errors for invalid userId

Add your answer

Q3. Write a global exception handler class to handle UserNotFound exception.

Ans.

Create a global exception handler class for UserNotFound exception.

  • Create a class that extends ExceptionHandler class

  • Override the handleException method to handle UserNotFound exception

  • Implement the logic to handle the exception, such as logging or returning a custom error message

Add your answer

Q4. What are different sorting algorithms?

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

Q5. SOLID Principle and best coding practices

Ans.

SOLID principles and best coding practices are essential for creating maintainable and scalable software.

  • S - Single Responsibility Principle: Each class should have only one responsibility.

  • O - Open/Closed Principle: Classes should be open for extension but closed for modification.

  • L - Liskov Substitution Principle: Subtypes should be substitutable for their base types.

  • I - Interface Segregation Principle: Clients should not be forced to depend on interfaces they do not use.

  • D - ...read more

Add your answer

Q6. Optional Class, Stream.map() vs Stream.flatMap()

Ans.

Stream.map() transforms each element in a stream, while Stream.flatMap() transforms each element into a stream of values.

  • map() applies a function to each element in a stream and returns a new stream with the transformed elements.

  • flatMap() applies a function that returns a stream for each element in the original stream, then flattens the streams into a single stream of values.

  • Example: map() - Stream.of(1, 2, 3).map(x -> x * 2) returns Stream.of(2, 4, 6).

  • Example: flatMap() - St...read more

Add your answer
Are these interview questions helpful?

Q7. Print all duplicate elements in an Array

Ans.

Print duplicate elements in an Array of strings

  • Iterate through the array and use a HashMap to store frequency of each element

  • Print elements with frequency greater than 1 as duplicates

Add your answer

Q8. Advantages of IOC in spring and DI

Ans.

IOC in Spring and DI offer flexibility, maintainability, and testability in software development.

  • Promotes loose coupling between components

  • Allows for easier unit testing and mocking

  • Facilitates easier configuration and management of dependencies

  • Enables better separation of concerns

  • Promotes reusability of components

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Top view of a binary tree

Ans.

A top view of a binary tree shows the nodes visible from the top when looking down from the root node.

  • The top view of a binary tree can be obtained by performing a level order traversal and keeping track of the horizontal distance of each node from the root.

  • Nodes with the same horizontal distance are at the same level in the top view.

  • Example: For the binary tree 1 -> 2 -> 3 -> 4 -> 5, the top view would be 1 -> 2 -> 3 -> 4 -> 5.

Add your answer

Q10. Spring IOC and types.

Ans.

Spring IOC (Inversion of Control) is a design pattern where the control of object creation and lifecycle is shifted to a container.

  • In Spring IOC, objects are created and managed by the Spring container.

  • Types of Spring IOC include Constructor-based dependency injection and Setter-based dependency injection.

  • Example: In Constructor-based dependency injection, dependencies are provided through the constructor of a class.

  • Example: In Setter-based dependency injection, dependencies ...read more

Add your answer

Q11. Circuit Breaker and its states

Ans.

Circuit Breaker is a design pattern used in software development to prevent system overload and failures.

  • Circuit Breaker monitors the number of failures and opens when a threshold is reached.

  • It can be in states like closed, open, or half-open.

  • Closed state allows normal operation, open state prevents further requests, and half-open state allows limited requests to check if the system is back to normal.

  • Examples include Hystrix in Java and Polly in .NET.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Top Bounteous x Accolite Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
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