Code Pumpkin

Morgan Stanley Interview Questions – Set 3

September 28, 2017
Posted by Rahul Jain

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

  1. Tell me about your current and past work expierience.
  2. What are your roles and responsibilities in your current project?

Multithreading

  1. 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 use ScheduledThreadPoolExecutor from Executor framework.
  2. Write a code snippet which may cause a deadlock?  
  3. Write a code snippet for inter thread communication which will always lead to a deadlock?

Java Memory Model

  1. 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
  2. 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.
  3. Is stack area is different for each thread?
    Ans : Yes. For every thread, JVM create one run-time stack.
  4. 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 

  1. JVM Architecture Introduction
  2. Class Loader SubSystem
  3. Types of Class Loader and Delegation Algorithm

Generic Methods and class

  1. If Child class extends Parent class and I am having List< Parent >, can I store Child class object in List<Parent>?
  2. Can I assign refernce variable of type List< Child >  to the reference variable of type List< Parent >?
  3. What is the use of extends and super in generics?
  4. 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

  1. How HashMap works internally? (Answer)
  2. Explain about hashCode()  and  equals() method.
  3. is it required to implement both hashCode() and equals()  method. What happens if we don't implement any one of them?
  4. If I want to maintain insertion order, which data structure should I use?
    Ans : LinkedHashMap
  5. How LinkedHashMap maintains insertion order internally? How put() and get() methods of LinkedHashMap is different than HashMap put() and get() methods?
  6. How to sort an HashMap based on its values?
  7. How ConcurrentHashMap work internally?
  8. How put() and get() method works in ConcurrentHashMap?
  9. How size() method works in ConcurrentHashMap?
  10. 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: , , , , , , , , ,


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.
Total Posts : 124
follow us in feedly

Like Us On Facebook