Morgan Stanley Interview Questions – Set 3
I have appeared for Java Developer requirement at Wissen Infotech, Bangalore Location. Requirement was for their client Morgan Stanley and it was my first telephonic interview round with Morgan Stanley. Duration : 1 hour.
I have also shared my interview experience with Wissen Infotech as well as my second interview round with Morgan Stanley..
Introduction and Project discussion
- Tell me about your current and past work expierience.
- What are your roles and responsibilities in your current project?
Multithreading
-
If you want implement your own scheduler for running processes or jobs, how you will implement it using core Java? without using any framework.
Ans : We can useScheduledThreadPoolExecutor
from Executor framework. - Write a code snippet which may cause a deadlock?
- Write a code snippet for inter thread communication which will always lead to a deadlock?
Java Memory Model
-
How many types of memory areas are there in JVM? Explain all of them.
Ans : Method area, Heap Area, Stack Area, PC Registers and Native Stack Area.
For detailed understanding, please refer our article Various Memory Areas of JVM -
What is the difference between Heap Space and PermGen Space?
Ans : Objects are created in Heap Space, where as all class level information like class name, immediate parent class name, static variables, methods and instance variables information are stored in PermGen Space. -
Is stack area is different for each thread?
Ans : Yes. For every thread, JVM create one run-time stack. - How memory is being managed for different methods which are being executed by the same thread?
To know more about JVM internals, refer below articles
Generic Methods and class
-
If Child class extends Parent class and I am having
List< Parent >
, can I store Child class object inList<Parent>
? -
Can I assign refernce variable of type
List< Child >
to the reference variable of typeList< Parent >
? -
What is the use of
extends
andsuper
in generics? - If my method m1 takes parameters as Parent i.e.
public Class Demo { public static void m1(Parent p) { System.out.println("m1"); } }
Can I call m1()
method as below:
Demo.m1(new Child());
Java Collections
-
How
HashMap
works internally? (Answer) - Explain about hashCode() and equals() method.
-
is it required to implement both
hashCode()
andequals()
method. What happens if we don't implement any one of them? -
If I want to maintain insertion order, which data structure should I use?
Ans :LinkedHashMap
-
How
LinkedHashMap
maintains insertion order internally? Howput()
andget()
methods ofLinkedHashMap
is different thanHashMap
put() and get() methods? -
How to sort an
HashMap
based on its values? -
How
ConcurrentHashMap
work internally? -
How
put()
andget()
method works inConcurrentHashMap
? -
How
size()
method works inConcurrentHashMap
? - Write your own Map implementation which will preserve all the values for same key.
For Example,
MyCustomMap<String,Language> m = new MyCustomMap<>(); //Language is my custom class
m.put("Mahesh",English);
m.put("Malay",Hindi);
m.put("Mahesh",Gujarati);
m.put("Ankit",German);
– In normal HashMap implementation, when we call m.put("Mahesh","Gujarati"), it will overwrite old value of English with Gujarati. But you need to maintain list of all the values like <"Mahesh" , {English,Gujarati}>
– Implement all the utility methods of Map interface like add(), remove(), containsKey(), size(), iterator(), etc.
– Also your map should work correctly and effieciently in multithreading enviornments.
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, Concurrency, Core Java, Generics, HashMap, Java, Java Memory Model, JVM internals, Multithreading
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.