Code Pumpkin

Morgan Stanley Interview Questions – Set 4

October 8, 2017
Posted by Pumpkin

I have appeared for Sr Java Developer position at Synechron Technologies. This was my first round with Synechron's client Morgan Stanley. It was a telephonic round. Duration : 1 hour

Introduction

  1. Please tell me about technologies you have worked on, your current project and  your roles and responsibility in it.

Core Java

  1. How HashMap works internally? explain about hashCode()  and  equals() methood?  (Answer)
  2. hashCode() method internally calls hash(int h) function. What is the use of hash() function? What does it do?
  3. What is rehashing? How HashMap does rehashing internally?
  4. Write a java program to implement a custom Map implementation for MarketPlace which internally maintais key-value pairs of stocks and its 10 last updated values.
    – If you put key-value in map, it should not overwrite old value, but instead maintain list of values.
    – Once size of list reaches to 10, it should remove old value. In short  it should maintain insertion order.
    For Example, 
                 
    MarketPlace<stock,listOfValues>
                      – If at 1:00 PM, stock value of Apple is 155.30 USD
                      – At 1:05 PM, stock value of Apple is 155.50 USD​
                  i.e. MarketPace < Apple, (155.50, 155.30) >

    – Write all the utility methods of this custom Map like put(), get(), containsKey(), remove(), size()
    – Map should also perform efficietnly and consistently in multithreading environments.

  5. Why ConcurrentHashMap provides better performance than SynchronizedMap
    Answer:

    – SynchronizedMap is a thread-safe, but it will acquire lock on entire Map in read and write opearations. So at a time only one thread can either read or write in Synchronized Map. Hence it is slower.

    ConcurrentHashMap is a thread-safe. Instead of acquireing a lock on entire Map object, it 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.

    – For detailed understanding, please read our article Hashtable Vs SynchronizedMap Vs ConcurrentHashMap

  6. How CopyOnArrayList works?
  7. What is the difference between LinkedHashSet and LinkedList?

Spring

  1. Which all Spring modules have you used?
  2. Explain Spring MVC life cycle.
  3. Explain various bean scopes of Spring?
  4. What is singleton bean scope?
  5. If I am having Spring Configuration file as below :

<beans>
    <bean id="emp1" class="Employee">
        ...
    </bean>
    <bean id="emp2" class="Employee">
        ...
    </bean>
</beans>

If I call getBean("emp1") and getBean("emp2"), How many Employee class objects will be created in JVM?    


Design Pattern

  1. What is the difference between Spring Singleton Bean scope and Singleton design pattern.
  2. How you will implement Singleton Design Pattern?
  3. What is double check in lazy intialization singleton pattern implementation?

SQL

  1. What is index in database table? When do we need to create index on table?
  2. Difference between clustered and non-clustered index
  3. Design Database table design for Bank's customers and thier account.
  4. When creating extra mapping table is useful.
  5. Write a SQL query to find 3rd largest salary

This article is contributed anonymously by one of the CodePumpkin user. If you would also like to contribute your article or share interview experiences, you can create contributor account with CodePumpkin by clicking here or you can send us a mail at admin@codepumpkin.com.

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


A Blog that will help you to learn and refresh your knowledge on Core Java, Data Structure, algorithms, Design Patterns.



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