Morgan Stanley
Visionet Systems Interview Questions and Answers
Q1. Max Element After Update Operations
Given an array A
of size N
, initialized with all zeros, and another array ARR
of M
pairs of integers representing operations. Each operation consists of a range where each el...read more
Find the maximum element in an array after performing a series of increment operations on specified ranges.
Initialize an array of size N with all zeros
Iterate through the operations and increment elements within specified ranges
Return the maximum element in the array after all operations
Use two threads to print even and odd numbers in increasing order.
Create two threads, one for printing even numbers and one for printing odd numbers.
Use a shared variable to keep track of the current number to be printed.
Synchronize access to the shared variable to ensure correct ordering of numbers.
Use a loop in each thread to print the next number and update the shared variable.
HashMap in Java is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values based on keys.
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 find 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.
Retrieving a value involves hashing the key to find the index and then traversing the linke...read more
Overriding equals and hashCode methods in Java is important for proper object comparison and hashing.
Equals method is used to compare two objects for equality, while hashCode method is used to generate a unique integer value for an object.
By overriding equals and hashCode methods, we can ensure that objects are compared based on their actual content rather than memory address.
This is crucial for collections like HashMap and HashSet, where proper implementation of equals and h...read more
Synchronized Collection is thread-safe but may have performance issues, while Concurrent Collection is optimized for concurrent access.
Synchronized Collection uses synchronized keyword to achieve thread-safety, while Concurrent Collection uses non-blocking algorithms like CAS (Compare and Swap).
Synchronized Collection locks the entire collection during modification, leading to potential performance bottlenecks, while Concurrent Collection allows multiple threads to access and...read more
CopyOnWriteArrayList creates a new copy of the underlying array whenever an element is added, modified, or removed.
CopyOnWriteArrayList is thread-safe and suitable for scenarios where reads are more frequent than writes.
Adding, modifying, or removing elements in CopyOnWriteArrayList creates a new copy of the underlying array, ensuring thread safety.
Iterators on CopyOnWriteArrayList operate on the original array and do not throw ConcurrentModificationException.
Q7. Reverse string with spaces but keep the space position intact
Reverse a string while keeping the position of spaces intact
Split the string into an array of characters
Iterate through the array and reverse the characters while keeping track of space positions
Join the array back into a string
Interview Process at Visionet Systems
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month