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

Senior Software Engineer

CGI
upvote
share-icon
3 rounds | 16 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: Java , Design Patterns, MVC , Spring Boot, Hibernate, Microservices
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.

Application process
Where: Referral
Eligibility: Above 2 years of experience
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Video Call
Duration60 Minutes
Interview date30 Jun 2021
Coding problem7

This round started with some basic questions from Java followed by some questions from Multithreading in Java and Java Design Patterns.

1. Java Question

What are the advantages of Packages in Java?

Problem approach

There are various advantages of defining packages in Java.

i) Packages avoid the name clashes.
ii) The Package provides easier access control.
iii) We can also have the hidden classes that are not visible outside and used by the package.
iv) It is easier to locate the related classes.

2. Java Question

Why Java is platform independent and JVM platform dependent?

Problem approach

JVM is platform dependent because it takes java byte code and generates byte code for the current operating
system. So Java software is platform dependent but Java language is platform independent because different
operating system have different JVMs.

3. Java Question

Explain the use of final keyword in variable, method and class.

Problem approach

In Java, the final keyword is used as defining something as constant /final and represents the non-access modifier.

1) final variable :
i) When a variable is declared as final in Java, the value can’t be modified once it has been assigned.
ii) If any value has not been assigned to that variable, then it can be assigned only by the constructor of the class.

2) final method :
i) A method declared as final cannot be overridden by its children's classes.
ii) A constructor cannot be marked as final because whenever a class is inherited, the constructors are not inherited. Hence, marking it final doesn't make sense. Java throws compilation error saying - modifier final not allowed here

3) final class:
i) No classes can be inherited from the class declared as final. But that final class can extend other classes for its usage.

4. Multithreading Question

Explain thread pool?

Problem approach

1) A Thread pool is simply a collection of pre-initialized or worker threads at the start-up that can be used to execute tasks and put back in the pool when completed. 

2) It is referred to as pool threads in which a group of fixed-size threads is created. 

3) By reducing the number of application threads and managing their lifecycle, one can mitigate the issue of performance using a thread pool. 

4) Using threads, performance can be enhanced and better system stability can occur. To create the thread pools, java.util.concurrent.Executors class usually provides factory methods.

5. Multithreading Question

What is race condition in Java? Given one example.

Problem approach

Race condition are cause of some subtle programming bugs when Java programs are exposed to concurrent execution environment. As the name suggests, a race condition occurs due to race between multiple threads, if a thread which is supposed to execute first lost the race and executed second, behaviour of code changes, which surface as non-deterministic bugs. This is one of the hardest bugs to find and re-produce because of random nature of racing between threads. One example of race condition is out-of-order processing.

6. Multithreading Question

What is the difference between the interrupted() and isInterrupted() method in Java?

Problem approach

1) Main difference between interrupted() and isInterrupted() is that former clears the interrupt status while later does not. 

2) The interrupt mechanism in Java multi-threading is implemented using an internal flag known as the interrupt status. Interrupting a thread by calling Thread.interrupt() sets this flag. 

3) When interrupted thread checks for an interrupt by invoking the static method Thread.interrupted(), interrupt status is cleared. The non-static isInterrupted() method, which is used by one thread to query the interrupt status of another, does not change the interrupt status flag. 

4) By convention, any method that exits by throwing an InterruptedException clears interrupt status when it does so. 

5) However, it's always possible that interrupt status will immediately be set again, by another thread invoking interrupt

7. Java Design Pattern Question

Explain the Singleton pattern?

Problem approach

Singleton pattern in Java is a pattern which allows a single instance within an application. One good example of the singleton pattern is java.lang.Runtime.

Singleton Pattern states that define a class that has only one instance and provides a global point of access to it.

In other words, it is the responsibility of the class that only a single instance should be created, and all other classes can use a single object.

02
Round
Medium
Video Call
Duration60 Minutes
Interview date30 Jun 2021
Coding problem7

This round primarily focused on some major concepts in Spring Boot and Hibernate and had questions revolving around that.

1. Spring Boot Question

What Are the Basic Annotations that Spring Boot Offers?

Problem approach

The primary annotations that Spring Boot offers reside in its "org.springframework.boot.autoconfigure" and its sub-
packages. Here are a couple of basic ones:

@EnableAutoConfiguration – to make Spring Boot look for auto-configuration beans on its classpath and
automatically apply them.

@SpringBootApplication – used to denote the main class of a Boot Application. This annotation combines
@Configuration, @EnableAutoConfiguration, and @ComponentScan annotations with their default attributes.

2. Spring Boot Question

Explain @RestController annotation in Sprint boot?

Problem approach

It is a combination of @Controller and @ResponseBody, used for creating a restful controller. It converts the
response to JSON or XML. It ensures that data returned by each method will be written straight into the response
body instead of returning a template.

3. Spring Boot Question

What is dependency Injection?

Problem approach

The process of injecting dependent bean objects into target bean objects is called dependency injection.

1) Setter Injection: The IOC container will inject the dependent bean object into the target bean object by calling the setter method.

2) Constructor Injection: The IOC container will inject the dependent bean object into the target bean object by calling the target bean constructor.

3) Field Injection: The IOC container will inject the dependent bean object into the target bean object by Reflection API.

4. Hibernate Question

What is hibernate caching?

Problem approach

Hibernate caching is the strategy for improving the application performance by pooling objects in the cache so that the queries are executed faster. Hibernate caching is particularly useful when fetching the same data that is executed multiple times. Rather than hitting the database, we can just access the data from the cache. This results in reduced throughput time of the application.

Types of Hibernate Caching

First Level Cache :

1) This level is enabled by default.
2) The first level cache resides in the hibernate session object.
3) Since it belongs to the session object, the scope of the data stored here will not be available to the entire application as an application can make use of multiple session objects.

Second Level Cache :

1) Second level cache resides in the SessionFactory object and due to this, the data is accessible by the entire application.
2) This is not available by default. It has to be enabled explicitly.
3) EH (Easy Hibernate) Cache, Swarm Cache, OS Cache, JBoss Cache are some example cache providers.

5. Hibernate Question

Can you tell the difference between setMaxResults() and setFetchSize() of Query?

Problem approach

setMaxResults() the function works similar to LIMIT in SQL. Here, we set the maximum number of rows that we want to be returned. This method is implemented by all database drivers.

setFetchSize() works for optimizing how Hibernate sends the result to the caller for example: are the results buffered, are they sent in different size chunks, etc. This method is not implemented by all the database drivers.

6. Hibernate Question

Can you tell something about the N+1 SELECT problem in Hibernate?

Problem approach

N+1 SELECT problem is due to the result of using lazy loading and on-demand fetching strategy. Let's take an example. If you have an N items list and each item from the list has a dependency on a collection of another object, say bid. In order to find the highest bid for each item while using the lazy loading strategy, hibernate has to first fire 1 query to load all items and then subsequently fire N queries to load big of each item. Hence, hibernate actually ends up executing N+1 queries.

7. Hibernate Question

What are the concurrency strategies available in hibernate?

Problem approach

Concurrency strategies are the mediators responsible for storing and retrieving items from the cache. While enabling second-level cache, it is the responsibility of the developer to provide what strategy is to be implemented to decide for each persistent class and collection.

Following are the concurrency strategies that are used:

1) Transactional: This is used in cases of updating data that most likely causes stale data and this prevention is most critical to the application.

2) Read-Only: This is used when we don't want the data to be modified and can be used for reference data only.

3) Read-Write: Here, data is mostly read and is used when the prevention of stale data is of critical importance.

4) Non-strict-Read-Write: Using this strategy will ensure that there wouldn't be any consistency between the database and cache. This strategy can be used when the data can be modified and stale data is not of critical concern.

03
Round
Easy
HR Round
Duration30 Minutes
Interview date30 Jun 2021
Coding problem2

This is a cultural fitment testing round .HR was very frank and asked standard questions. Then we discussed about my
role.

1. Basic HR Question

Why should we hire you ?

Problem approach

Tip 1 : The cross questioning can go intense some time, think before you speak.

Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.

Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round,
like what are the projects currently the company is investing, which team you are mentoring. How all is the work
environment etc.

Tip 4 : Since everybody in the interview panel is from tech background, here too you can expect some technical
questions. No coding in most of the cases but some discussions over the design can surely happen.

2. Basic HR Question

Why are you looking for a job change?

Problem approach

Tip : For an experienced professional seeking a change, this is a common question. The easiest method to respond
to this question is to state that you are leaving your current work in order to advance your career. Make sure you don't
criticize or speak poorly about the company where you now work

Here's your problem of the day

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

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
company logo
Software Testing Engineer
3 rounds | 16 problems
Interviewed by CGI
1261 views
0 comments
0 upvotes
company logo
Senior Test Engineer
3 rounds | 16 problems
Interviewed by CGI
1041 views
0 comments
0 upvotes
company logo
Senior Software Engineer
3 rounds | 17 problems
Interviewed by CGI
1518 views
0 comments
0 upvotes
company logo
Data Engineer
2 rounds | 4 problems
Interviewed by CGI
875 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Senior Software Engineer
1 rounds | 6 problems
Interviewed by Arcesium
3734 views
0 comments
0 upvotes
company logo
Senior Software Engineer
3 rounds | 3 problems
Interviewed by Ernst & Young (EY)
4984 views
0 comments
0 upvotes
company logo
Senior Software Engineer
3 rounds | 3 problems
Interviewed by HCL Technologies
3014 views
3 comments
0 upvotes