Pinesucceed Technologies
Larsen & Toubro Limited Interview Questions and Answers
Q1. Explain association, aggregation and composition.
Association, aggregation, and composition are types of relationships between classes in object-oriented programming.
Association is a relationship where two classes are related in some way, but not dependent on each other. Example: a student and a teacher.
Aggregation is a type of association where one class contains a reference to another class, but the referenced class can exist independently. Example: a car has an engine.
Composition is a type of aggregation where one class c...read more
Q2. Find a number in a rotated sorted array
Use binary search to find the target number in a rotated sorted array.
Use binary search to find the pivot point where the array is rotated.
Determine which half of the array the target number lies in based on the pivot point.
Continue binary search in the appropriate half of the array to find the target number.
Q3. Print the left view of tree
Printing the left view of a tree involves printing the leftmost nodes at each level of the tree.
Traverse the tree using a level order traversal (BFS)
At each level, print the first node encountered
Repeat for each level until all nodes are visited
Q4. Diff bw put and post mapping
PUT is used to update or replace an existing resource, while POST is used to create a new resource.
PUT is idempotent, meaning multiple identical requests will have the same effect as a single request.
POST is not idempotent, meaning multiple identical requests may have different effects.
PUT is typically used for updating an existing resource, like updating a user's information.
POST is typically used for creating a new resource, like adding a new user to a database.
Q5. Explain functional interface
Functional interface is an interface with only one abstract method, used for lambda expressions.
Functional interfaces can have multiple default or static methods, but only one abstract method.
They are used for lambda expressions and method references in Java.
Examples of functional interfaces in Java include Runnable, Callable, and Comparator.
Q6. Internal working of hashmap
HashMap is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values.
HashMap internally uses an array of linked lists to store key-value pairs.
When a key-value pair is added, the key is hashed to determine the index in the array where it will be stored.
If multiple keys hash to the same index, a linked list is used to handle collisions.
To retrieve a value, the key is hashed again to find the index and then the linked list is traversed to find...read more
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month