Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Infosys interview experience Real time questions & tips from candidates to crack your interview

Java Developer

Infosys
upvote
share-icon
3 rounds | 16 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Java , OOPS , Spring , MVC , Hibernate , Aptitude
Tip
Tip

Tip 1 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 2 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Referral
Eligibility: 1+ 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 date9 Sep 2021
Coding problem7

This round primarily focused on OOPS in Java and how Multithreading is achieved in Java and the interviewer asked questions revolving around that only.

1. OOPS 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.

2. OOPS Question

How would you differentiate between a String, StringBuffer, and a StringBuilder?

Problem approach

1) Storage area : In string, the String pool serves as the storage area. For StringBuilder and StringBuffer, heap memory is the storage area.

2) Mutability : A String is immutable, whereas both the StringBuilder and StringBuffer are mutable.

3) Efficiency : It is quite slow to work with a String. However, StringBuilder is the fastest in performing operations. The speed of a StringBuffer is more than a String and less than a StringBuilder. (For example appending a character is fastest in StringBuilder and very slow in String because a new memory is required for the new String with appended character.)

4) Thread-safe : In the case of a threaded environment, StringBuilder and StringBuffer are used whereas a String is not used. However, StringBuilder is suitable for an environment with a single thread, and a StringBuffer is suitable for multiple threads.

3. OOPS Question

Which among String or String Buffer should be preferred when there are lot of updates required to be done in the data?

Problem approach

StringBuffer is mutable and dynamic in nature whereas String is immutable. Every updation / modification of String creates a new String thereby overloading the string pool with unnecessary objects. Hence, in the cases of a lot of updates, it is always preferred to use StringBuffer as it will reduce the overhead of the creation of multiple String objects in the string pool.

4. Java Question

What's the difference between User thread and Daemon thread?

Problem approach

User and Daemon are basically two types of thread used in Java by using a ‘Thread Class’. 

User Thread : 

1) JVM waits for user threads to finish their tasks before termination. 
2) These threads are normally created by the user for executing tasks concurrently. 
3) They are used for critical tasks or core work of an application. 
4) These threads are referred to as high-priority tasks, therefore are required for running in the foreground. 


Daemon Thread : 

1) JVM does not wait for daemon threads to finish their tasks before termination.
2) These threads are normally created by JVM.
3) They are not used for any critical tasks but to do some supporting tasks.
4) These threads are referred to as low priority threads, therefore are especially required for supporting background tasks like garbage collection, releasing memory of unused objects, etc.

5. Java Question

Difference b/w Runnable Interface and Callable Interface

Problem approach

Both Runnable and Callable interfaces are generally used to encapsulate tasks that are needed to be executed by another thread. But there are some differences between them as given below : 

Runnable Interface :

1) It does not return any result and therefore, cannot throw a checked exception. 
2) It cannot be passed to invokeAll method. 
3) It was introduced in JDK 1.0.
4) It simply belongs to Java.lang.
5) It uses the run() method to define a task.
6) To use this interface, one needs to override the run() method. 


Callable Interface : 

1) It returns a result and therefore, can throw an exception.
2) It can be passed to invokeAll method.
3) It was introduced in JDK 5.0, so one cannot use it before Java 5. 
4) It simply belongs to java.util.concurrent. 
5) It uses the call() method to define a task. 
6) To use this interface, one needs to override the call() method.

6. Java Question

What is thread starvation?

Problem approach

Thread starvation is basically a situation or condition where a thread won’t be able to have regular access to shared resources and therefore is unable to proceed or make progress. This is because other threads have high priority and occupy the resources for too long. This usually happens with low-priority threads that do not get CPU for its execution to carry on.

7. OOPS Question

What is Garbage collector in JAVA?

Problem approach

1) Garbage Collection in Java is a process by which the programs perform memory management automatically.

2) The Garbage Collector(GC) finds the unused objects and deletes them to reclaim the memory. 

3) In Java, dynamic memory allocation of objects is achieved using the new operator that uses some memory and the
memory remains allocated until there are references for the use of the object.

4) When there are no references to an object, it is assumed to be no longer needed, and the memory, occupied by
the object can be reclaimed.

5) There is no explicit need to destroy an object as Java handles the de-allocation automatically.
The technique that accomplishes this is known as Garbage Collection. Programs that do not de-allocate memory can
eventually crash when there is no memory left in the system to allocate. These programs are said to have memory
leaks.


Garbage collection in Java happens automatically during the lifetime of the program, eliminating the need to de-
allocate memory and thereby avoiding memory leaks.

In C language, it is the programmer’s responsibility to de-allocate memory allocated dynamically using free()
function.This is where Java memory management leads.

02
Round
Medium
Video Call
Duration60 Minutes
Interview date9 Sep 2021
Coding problem7

This round had questions revolving mainly around Spring and MVC Architecture.

1. Spring Boot Question

How to enable debugging log in the spring boot application?

Problem approach

Debugging logs can be enabled in three ways -

1) We can start the application with --debug switch.
2) We can set the logging.level.root=debug property in application.property file.
3) We can set the logging level of the root logger to debug in the supplied logging configuration file.

2. 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.

3. Spring Boot Question

What is the @Controller annotation used for? How can you create a controller without an annotation?

Problem approach

The @Controller is a Spring MVC annotation to define Controller but in reality, it's just a stereotype annotation. You can even create a controller without @Controller by annotating the Spring MVC Controller classes using @Component annotation. The real job of request mapping to the handler method is done using @RequestMapping annotation.

4. MVC Question

What is the root application context in Spring MVC? How is it loaded?

Problem approach

In Spring MVC, the context loaded using ContextLoaderListener is called the "root" application context which belongs to the whole application while the one initialized using DispatcherServlet is actually specific to that servlet.

Technically, Spring MVC allows multiple DispatcherServlet in a Spring MVC web application and so multiple such contexts each specific for respective servlet but having the same root context may exist.

5. MVC Question

What are the different properties of MVC routes?

Problem approach

MVC routes are accountable for governing which controller method will be executed for a given URL. Thus, the URL comprises of the following properties :

1) Route Name : It is the URL pattern which is used for mapping the handler.

2) URL Pattern : It is another property containing the literal values as well as variable placeholders (known as URL parameters).

3) Defaults : This is the default parameter value assigned at the time of parameter creation.

4) Constraints : These are used for applying against the URL pattern for more narrowly defining the URL matching it.

6. MVC Question

How is the routing carried out in MVC?

Problem approach

1) The RouteCollection contains a set of routes that are responsible for registering the routes in the application. 

2) The RegisterRoutes method is used for recording the routes in the collection. 

3) The URL patterns are defined by the routes and a handler is used which checks the request matching the pattern. 

4) The MVC routing has 3 parameters. 
4.1) The first parameter determines the name of the route. 
4.2) The second parameter determines a specific pattern with which the URL matches. 
4.3) The third parameter is responsible for providing default values for its placeholders.

7. MVC Question

Difference b/w View and Partial View

Problem approach

View : 

1) The view is not as lightweight as that of Partial view.
2) The view has its own layout page.
3) The Viewstart page is rendered just before rendering any view.
4) The view can have markup tags of HTML such as HTML, head, body, title, meta, etc.


Partial View : 

1) Partial view, as the name suggests, is lightweight than View.
2) The partial view does not have its own layout page.
3) Partial view is designed particularly for rendering within the view.
4) The partial view does not contain any markup.

03
Round
Easy
HR Round
Duration30 Minutes
Interview date9 Sep 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

Tell me something not there in your resume.

Problem approach

If you get this question, it's an opportunity to choose the most compelling information to share that is not obvious from
your resume.

Example :

Strength -> I believe that my greatest strength is the ability to solve problems quickly and efficiently, which makes me
unique from others.

Ability to handle Pressure -> I enjoy working under pressure because I believe it helps me grow and become more
efficient.


Tip : Emphasize why you were inspired to apply for the job. You can also explain that you are willing to invest a great
deal of energy if hired.

These are generally very open ended questions and are asked to test how quick wit a candidate is. So there is
nothing to worry about if you have a good command over your communication skills and you are able to propagate
your thoughts well to the interviewer.

2. 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.

Join the Discussion
1 reply
profile
17 May 2023

.

0 upvotes
0 replies
Reply
Similar interview experiences
company logo
Java Developer
3 rounds | 14 problems
Interviewed by Infosys
4525 views
1 comments
0 upvotes
company logo
Java Developer
3 rounds | 15 problems
Interviewed by Infosys
46430 views
3 comments
0 upvotes
company logo
Digital Specialist Engineer
3 rounds | 5 problems
Interviewed by Infosys
625 views
0 comments
0 upvotes
company logo
Power Programmer
4 rounds | 5 problems
Interviewed by Infosys
429 views
0 comments
0 upvotes
Companies with similar interview experiences
Java Developer
3 rounds | 20 problems
Interviewed by Ernst & Young (EY)
4139 views
2 comments
0 upvotes
company logo
Java Developer
2 rounds | 3 problems
Interviewed by Tata Consultancy Services (TCS)
7970 views
0 comments
0 upvotes
company logo
Java Developer
2 rounds | 2 problems
Interviewed by HCL Technologies
237 views
0 comments
0 upvotes