Code Pumpkin

Morgan Stanley Interview Questions – Set 2

September 23, 2017
Posted by Sejal Thakkar

I have cleared three rounds of Synechron and after that they scheduled my telephonic interview with their client Morgan Stanley.  This round was more focused on Core Java, SQL and Problem solving skills. Interviewer also asked few questions on Spring framework. 


Problem Solving / Programming

  1. For a given interger array, find two subarray of size 2 whose sum is equal.

For example, 
input : 
 int[] inputArr = {1,2,3,4,5};
output : 
  {1,4} and {2,3} as some of both these array is 5.
  

  1. Write a java program to find nth element from last in the SinglyLinkedList.
  2. Write a java program to detect and remove cycle in a Linked List.
  3. Write a java program to display all the elements of Binary Search Tree (BST) in sorted order.

Core Java

  1. Difference between StringBuilder and StringBuffer.
  2. How to create immutable object? (Answer)
  3. How to deal with the situation where one of the field in our immutable class is mutable? (Answer
  4. What do you know about threadpool in java? What are the advantages of threadpool? (Answer)
  5. What should we do to release all the resources of threadpool once we are done with execution of all the available tasks?
  6. How can we return a computation result from a thread? 
  7. What is Future object? How get() method of Future object should be used to avoid any unnecessary blocking?
  8. Difference between class level and object level synchronization.
  9. How does HashMap work internally? (Answer)
  10. Difference between HashMap, SynchronizedMap and ConcurrentHashMap.
    Answer : 
    ​- 
    HashMap is not thread-safe.


    – 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.

    HashMap and SynchronizedMap can have multiple null values and one null key whereas ConcurrentHashMap can not have any null keys or values. 

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


SQL

  1. What are the conditions of first Normal Form (1NF)?
  2. Do you know about any RAID concept?
  3. Design a table structure for a web application of Bank using following requirements.
  • We need to store customer data.
  • Customer can have different types of account like Savings, Current and Fixed Depoist.
  • You need to store Account Statement / transaction data for all customer accounts along with timestamp.
     

Also write below SQL queries using your table structure:

  • Write SQL query which will display account statement for given account number.
  • Write SQL query to display customer name, their account numbers and account balance for all the customers who owns more than 3 accounts.
     
  1. If I am having a database table with large data, what should I do to improve the speed of retrival?
  2. What is the difference between clustered and non clustered index?
  3. What is the difference between candidate key and primary key?
  4. What all things should be taken care to write efficient and optimized SQL Query. Tips for SQL performance tuning.

Spring

  1. What are the different types of dependency injections in spring?
  2. What are the different Types of Spring IOC Containers? Explain the difference?
  3. If I want to process something before initializing spring bean, how I will do that?
  4. Explain Spring Bean Life cycle?
  5. Explain Different types of Bean scope available in Spring?

    This article is contributed by Sejal Thakkar. 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





    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