Morgan Stanley Interview Questions – Set 5
I have appeared for Java Developer requirement at Wissen Infotech, Bangalore Location. Requirement was for their client Morgan Stanley and it was my second telephonic interview round with Morgan Stanley. Duration : 30 Minute.
I have also shared my interview experience with Wissen Infotech as well as my first interview round with Morgan Stanley.
- Tell me about your current Project.
- How to create Immutable class? (Answer)
- Suppose, I have class Employee with three fields as below:
class Employee{ int empId; String empName; Address empAddress; } class Address{ }
– How will I make Employee as Immutable class.
– If Address is also a mutable object. How will you handle it? (Answer)
- What is deep copy? How it will be useful in Immutable objects?
- How does HashMap work internally? tell me about hashCode() and equals() method.
- How does TreeMap work internally? Do we need to implement hashCode() and equals()?
- Which method should we implement in case of TreeMap?
-
Difference between HashMap and ConcurrentHashMap.
Answer :
-HashMap
is not thread-safe.
–ConcurrentHashMap
is a thread-safe.
– For detailed understanding, please read our article Hashtable Vs SynchronizedMap Vs ConcurrentHashMap -
How does ConcurrentHashMap work internally?
Answer :
– Instead of acquiring a lock on entire Map object like SynchronizedMap, ConcurrentHashMap devides map in different segements and each thread can aquire a lock on individual segment. so at a time multiple threads can write in different segments but not in the same segement. Also this lock is required only in write operation. Multiple threads can read concurrently from the same segement. - Tell me about ExecutorService.
- If I am having a file of size 10GB. I want process that file, how will I do that?
-
I am having array which is increasing upto one element and then it decreses. Find the pick elements.
For example,
10 30 40 50 20 5 4 1
Answer : 50
- For below given SQL Table
Emp_Id | Employee_Name | Mgr_Id |
---|---|---|
100 | Prateek | – |
101 | Kapil | 100 |
102 | Prakash | 101 |
103 | Jack | 101 |
Write a query to fetch result as below
Employee_Name | Manager_Name |
---|---|
Prateek | – |
Kapil | Prateek |
Prakash | Kapil |
Jack | Kapil |
This article is contributed by Rahul Jain. If you would also like to contribute your article or share interview experiences, you can create contributor account with codePumpkin by clicking here.
That's all for this topic. If you guys have any suggestions or queries, feel free to drop a comment. We would be happy to add that in our post. You can also contribute your articles by creating contributor account here.
Happy Learning 🙂
If you like the content on CodePumpkin and if you wish to do something for the community and the planet Earth, you can donate to our campaign for planting more trees at CodePumpkin Cauvery Calling Campaign.
We may not get time to plant a tree, but we can definitely donate ₹42 per Tree.
About the Author
Tags: Collection Framework, Collections, Core Java, HashMap, Java, Multithreading, SQL
Comments and Queries
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:<pre><code class="java"> String foo = "bar"; </code></pre>For more information on supported HTML tags in disqus comment, click here.