Cognizant interview experience Real time questions & tips from candidates to crack your interview

SDE - 2

Cognizant
upvote
share-icon
3 rounds | 11 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Core Java , OOPs concepts ,System design, design patterns , Spring , Hibernate, SQL, Microservices, Distributed system
Tip
Tip

Tip 1 : Prepare Basics 
Tip 2 : Explain your project very well in your resume
Tip 3 : Prepare by building projects

Application process
Where: Linkedin
Eligibility: Relevant experience of 3+ years as a Java developer
Resume Tip
Resume tip

Tip 1 : Explain your past projects very well
Tip 2 : Mention the tech stack you worked on ,and add the certifications

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 mins
Interview date17 Dec 2021
Coding problem2

1 coding question ,and Mcqs on spring ,hibernate ,sql and java questions

1. Remove Duplicates from Sorted Array

Easy
15m average time
85% success
0/40
Asked in companies
Tata Consultancy Services (TCS)Thought WorksGoldman Sachs

Remove Duplicates from Sorted Array

Problem approach

// simple java program to remove duplicates

class Main {
// Function to remove duplicate elements This function
// returns new size of modified array.
static int removeDuplicates(int arr[], int n)
{
// Return, if array is empty or contains a single
// element
if (n == 0 || n == 1)
return n;

int[] temp = new int[n];

// Start traversing elements
int j = 0;
for (int i = 0; i < n - 1; i++)
// If current element is not equal to next
// element then store that current element
if (arr[i] != arr[i + 1])
temp[j++] = arr[i];

// Store the last element as whether it is unique or
// repeated, it hasn't stored previously
temp[j++] = arr[n - 1];

// Modify original array
for (int i = 0; i < j; i++)
arr[i] = temp[i];

return j;
}

public static void main(String[] args)
{
int arr[] = { 1, 2, 2, 3, 4, 4, 4, 5, 5 };
int n = arr.length;

n = removeDuplicates(arr, n);

// Print updated array
for (int i = 0; i < n; i++)
System.out.print(arr[i] + " ");
}
}

// This code is contributed by Aditya Kumar (adityakumar129)

Try solving now

2. Technical question

Which of the following method can be used to used to instantiate a method?
a) static factory method
b) default-init method
c) destroy method
d) lazy-init method

Problem approach

Answer- static factory method
Explanation: Class attribute is used to specify the name of the class that contains the static factory method.

02
Round
Easy
Video Call
Duration60 mins
Interview date20 Dec 2021
Coding problem8

In afternoon ,Environment was good , Interviewer was good

1. Technical question

What is a Spring configuration file?

Problem approach

A Spring configuration file is an XML file. This file mainly contains the classes information. It describes how those classes are configured as well as introduced to each other. The XML configuration files, however, are verbose and more clean. If it’s not planned and written correctly, it becomes very difficult to manage in big projects.

2. Technical question

What do you mean by Dependency Injection?

Problem approach

In Dependency Injection, you do not have to create your objects but have to describe how they should be created. You don’t connect your components and services together in the code directly, but describe which services are needed by which components in the configuration file. The IoC container will wire them up together.

3. Technical question

How configuration metadata is provided to the Spring container?

Problem approach

Configuration metadata can be provided to Spring container in following ways:

XML-Based configuration: In Spring Framework, the dependencies and the services needed by beans are specified in configuration files which are in XML format. These configuration files usually contain a lot of bean definitions and application specific configuration options. They generally start with a bean tag. 



Annotation-Based configuration: Instead of using XML to describe a bean wiring, you can configure the bean into the component class itself by using annotations on the relevant class, method, or field declaration. By default, annotation wiring is not turned on in the Spring container. So, you need to enable it in your Spring configuration file before using it.
Java-based configuration: The key features in Spring Framework’s new Java-configuration support are @Configuration annotated classes and @Bean annotated methods.

4. Technical question

What are the uses of @RequestMapping and @RestController annotations in Spring Boot?

Problem approach

@RequestMapping:
This provides the routing information and informs Spring that any HTTP request matching the URL must be mapped to the respective method.
org.springframework.web.bind.annotation.RequestMapping has to be imported to use this annotation.
@RestController:
This is applied to a class to mark it as a request handler thereby creating RESTful web services using Spring MVC. This annotation adds the @ResponseBody and @Controller annotation to the class.
org.springframework.web.bind.annotation.RestController has to be imported to use this annotation.

5. Technical question

What is the use of @Autowired annotation? Explain with code

Problem approach

@Autowired annotation is meant for the injection of a bean by means of its type along with methods and fields. This helps the Spring framework to resolve dependencies by injecting and collaborating the beans into another bean. For example, consider the below code snippet

import org.Springframework.beans.factory.annotation.Autowired;
import java.util.*;
public class InterviewBit {
// Autowiring/Injecting FormatterUtil as dependency to InterviewBit class
@Autowired
private FormatterUtil formatterUtil;

public Date something( String value ){
Date dateFormatted = formatterUtil.formatDate(value);
return dateFormatted
}
}
/**
* Util class to format any string value to valid date format
*/
public class FormatterUtil {

public Date formatDate(String value){
//code to format date
}
}

6. Technical question

How is it possible to use the Tomcat JNDI DataSource in the Spring applications?

Problem approach

To use the servlet container which is configured in the JNDI (Java Naming and Directory Interface) DataSource, the DataSource bean has to be configured in the spring bean config file and then injected into the beans as dependencies. Post this, the DataSource bean can be used for performing database operations by means of the JdbcTemplate. The syntax for registering a MySQL DataSource bean:

7. Technical question

What do you understand by Content delivery network?

Problem approach

Content delivery network or in short CDN is a globally distributed proxy server network that serves content from locations close by to the end-users. Usually, in websites, static files like HTML, CSS, JS files, images and videos are served from CDN.

Using CDN in delivering content helps to improve performance:
Load on the servers is reduced significantly as some of the responsibility is shared by CDNs.
There are two types of CDNs, they are:

Push CDNs: Here, the content is received by the CDNs whenever changes occur on the server. The responsibility lies in us for uploading the content to CDNs. Content gets updated to the CDN only when it is modified or added which in turn maximises storage by minimising the traffic. Generally, sites with lesser traffic or content work well using push CDNs.
Pull CDNs: Here new content is grabbed from the server when the first user requests the content from the site. This leads to slower requests for the first time till the content gets stored/cached on the CDN. These CDNs minimizes space utilized on CDN but can lead to redundant traffic when expired files are pulled before they are changed. Websites having heavy traffic work well when used with pull CDNs.

8. Design question

How do you design a recommendation system?

Problem approach

Recommendation systems are used for helping users identify what they want efficiently by assisting them by offering various choices and alternatives based on their history or interests.

What are some of the Required Features?
Discuss what kind of recommendation system is required - whether it is for movies, e-commerce websites, songs etc.
What are some of the common problems encountered?
Figure out how to recommend fresh and relevant content in real-time.
Possible tips for consideration:
Discuss how to use the Eval component for understanding the working of the system.
Discuss how to train a collaborative filtering approach.

03
Round
Easy
HR Round
Duration30 mins
Interview date22 Dec 2021
Coding problem1

In evening , teams , good

1. Basic Hr Questions

my past experience,
some behavioral questions
how with you deal if your manager is not supportive
some package CTC negotiation
willing to relocate in case of project requirement

Problem approach

just be confident, answer point to point, communication skills should be good

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

To make an AI less repetitive in a long paragraph, you should increase:

Choose another skill to practice
Similar interview experiences
company logo
SDE - 2
2 rounds | 4 problems
Interviewed by Cognizant
750 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 5 problems
Interviewed by Cognizant
1063 views
0 comments
0 upvotes
company logo
Frontend Developer
3 rounds | 7 problems
Interviewed by Cognizant
2407 views
0 comments
0 upvotes
company logo
Programmer Analyst
3 rounds | 8 problems
Interviewed by Cognizant
952 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by HashedIn
9561 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by Arcesium
1774 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 3 problems
Interviewed by Tata Consultancy Services (TCS)
1744 views
0 comments
0 upvotes