LTIMindtree
Infosys Interview Questions and Answers
Q1. If I add 2 same attribute values for a object to a set...will I see 2 objects in the set, if yes what changes you make to the code to insert unique objects to a set
No, you will not see 2 objects in the set. To insert unique objects to a set, you can override the equals() and hashCode() methods in the object class.
In a set, each element must be unique based on the equals() method. If you add 2 objects with the same attribute values, only one will be stored in the set.
To ensure uniqueness, override the equals() and hashCode() methods in the object class. This will define how objects are compared and stored in the set.
For example, if you h...read more
Q2. Given a sorted array of integers, write a function to perform a binary search to find the index of a target value. If the target value is not found, return -1.
Binary search function to find target value in sorted array
Define function that takes sorted array and target value as input
Initialize variables for start, end, and middle indices
Use while loop to iterate until start is less than or equal to end
Q3. How is dependency injection different from dependency inversion
Dependency injection is a design pattern where dependencies are provided to a class from the outside, while dependency inversion is a principle that states high-level modules should not depend on low-level modules, but both should depend on abstractions.
Dependency injection is a technique to achieve dependency inversion.
Dependency injection involves providing dependencies to a class from the outside, typically through constructor injection or setter injection.
Dependency inver...read more
Q4. Write a Generic method to add string or integer to List or List
Create a generic method to add string or integer to List or List
Create a generic method that takes a List and an element as input
Use Java generics to specify the type of List and element
Check the type of List and element, then add the element to the List
Q5. What is serialisation, externalisation, serializable
Serialisation is the process of converting an object into a format that can be easily stored or transmitted. Externalisation is a way to customize the serialization process. Serializable is an interface in Java that allows objects to be serialized.
Serialisation is the process of converting an object into a format that can be easily stored or transmitted
Externalisation is a way to customize the serialization process
Serializable is an interface in Java that allows objects to be...read more
Q6. Given a string, write a function to reverse the string.
Function to reverse a given string
Create an empty string to store the reversed string
Iterate through the input string in reverse order and append each character to the new string
Return the reversed string
Q7. What is concurrent hashmap
ConcurrentHashMap is a thread-safe implementation of the HashMap class in Java.
ConcurrentHashMap allows multiple threads to read and write to the map concurrently without causing any data corruption.
It achieves thread-safety by dividing the map into segments, each of which can be locked independently.
ConcurrentHashMap is more efficient than using synchronized collections for concurrent access.
Example: ConcurrentHashMap
map = new ConcurrentHashMap<>();
Q8. What is dependency injection
Dependency injection is a design pattern in which components are given their dependencies rather than creating them internally.
Dependency injection helps in achieving loose coupling between classes.
It allows for easier testing and swapping of dependencies.
There are three types of dependency injection: constructor injection, setter injection, and interface injection.
Q9. What is solid principles
SOLID principles are a set of five design principles that help developers create more maintainable and scalable software.
S - Single Responsibility Principle: A class should have only one reason to change.
O - Open/Closed Principle: Software entities should be open for extension but closed for modification.
L - Liskov Substitution Principle: Objects of a superclass should be replaceable with objects of its subclasses without affecting the program's correctness.
I - Interface Segr...read more
More about working at LTIMindtree
Interview Process at Infosys
Top Full Stack Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month