Interview Preparation IV

Morgan Stanley

 

Telephone interview merely consisting of questions on concurrency and garbage collection. Also some questions on collections and project management.


Deadlock, Asked about how to avoid deadlock and how to detect them.


How does JVM manage cyclic references? Does JVM collect variables that have cyclic references? https://stackoverflow.com/questions/1910194/how-does-java-garbage-collection-work-with-circular-references

Java's GC considers objects "garbage" if they aren't reachable through a chain starting at a garbage collection root, so these objects will be collected. Even though objects may point to each other to form a cycle, they're still garbage if they're cut off from the root.


What are different types of locks in multi-threading? Do you know about semaphore lock?

https://stackoverflow.com/questions/41284183/how-many-types-of-locks-are-there-in-java

https://www.justsoftwaresolutions.co.uk/threading/locks-mutexes-semaphores.html

What is a good hashcode? How to generate hashcode? How does map.put work?

https://stackoverflow.com/questions/16629893/good-hashcode-implementation

what is the complexity of hashtable?

http://bigocheatsheet.com/

If you have a very large text file. You have comma separated characters. How do you know how many times a word appeared? How will you print the first maximum top 10 words.  


The first one is to find 1 item that has different weight among 8 items using scale. And then, I moved to final round. I met four interviewers each for 30 minutes. They gave questions from basic Java questions like Auto boxing, to practical questions such as sorting text files that has many columns, data tracking…


How to sort data in each columns in a file. Should put all data on memory.


what projects I worked on, on what parts specifically.


Hashing, Equals question: see Java API rules, good hashing, what if return 0; how HashMap works. Collections, basic, synchronized, concurrent, efficiency. Threading, blocking queue, volatile.

Problem solving: array with prices in time order, what is the worst buy-sell case? cant sell before buy.


Next Monday 4 times 1 hour long 1 to 1 interview.

Java equals, hashCode with examples. Final keyword in Java, final method, constructor in abstract class. Concurrency questions.

https://stackoverflow.com/questions/260666/can-an-abstract-class-have-a-constructor

Implement mergesort, impement printing (sub)folders, files, recursive, non-recursive,

How to test a 3rd party library with multiple threads: completion service or blocking queue.

4 employees in room, they want to know average salary without exposing it to anyone: how?


Implement mergesort,  


Java serialization and generics (the previous interviewers asked me core Java questions, including questions on concurrency and multi-threading).


What are the two functions you need to implement in a class in order to make it usable efficiently in Java Collections?  


How do you implement a singleton in Java? Make it thread-safe.  


What is the difference between a Running time exception and a normal exception


What is primary indexing?  https://stackoverflow.com/questions/20824686/what-is-difference-between-primary-index-and-secondary-index-exactly

Questions on Virtual functions


Data structures, Reverse linked list; Find loop in a Linked list; Binary Trees; Heaps


If u have fragmented memory. Design a data structure to use it and have properties of an array.


screening test involves 90 min hackerank test. It involves 2 coading (both dp) and 19 MCQ question.
coding question was: alternate binary string and matrix search.


Oops concept, Visualization, Paging, how inheritance works, algo to remove duplicate in LL, algo to detect loop in LL.


Technical had standard questions like Second Minimum, BST Traversal/ Deletion, Heaps,

OS(Virtual Memory, Paging, Segmentation, semaphores)


Linked list traversal, object oriented programming and time complexity were the main questions.


What is hashing?  

What can you tell me about exceptions in Java?  

What are some differences between linked lists and arrays?  

What are the different types of JOINs in SQL?  

A few questions on basic command-line syntax in Unix shells:

1. How would you log output and error messages from a command to a file? echo
2. How would you run the same command on every file in a directory?  find
3. How would you find the PID of a named process (say if you wanted to kill it)? ps aux



Find the last element of a link list


when do you use smart pointer?


what is the thead priorty for the main method

https://stackoverflow.com/questions/1269807/what-is-the-value-for-main-thread-priority (priority is 5)

describe strategy pattern.


swap number if different is 1 and if it is sorte print YES and write time and its space complexity

Query to find records present in table A but not in table B  

Find the Rotation Count in Rotated Sorted array  

  • - Abstract and interface

  • - Cloning and its types

  • - String

  • - Hashmap

  • - Binary tree question

  • - Design Executor Service  


Question about singleton design pattern...bean scopes of spring ...what is default bean scope on spring....give example for prototype bean scope and deafault bean scope....question about connection pooling ...how to create connection poling ...what is atomic transaction ...more questions on spring ....ioc container .....how to create api like @transactional annotation....implement transactional class....internal implementation on comparable and comparable interface ....design transactionals....how to handle the error in application....deep concepts about spring and Java ....level was very high ...not like service based companies .


Two telephonic interviews and 1 face to face 3 hours 5 people. one system design, two technical, 1 hr and 1 manager. It was good. and amazing experience. Its worth it to have a face to face interview with Morgan Stanley. One of the best experiences so far.


what is thread. What is deadlock. how to resolve a deadlock. read last nth element of linked list with one and only one traversal.  

http://www.geeksforgeeks.org/nth-node-from-the-end-of-a-linked-list/


Questions about core java, multithreading, collection, GC, j2ee, spring, hibernate, JMS, webservice,SQL and so on. Broad, but not too deep since its first round.  


  • An excel sheet has different rows and columns. For example, for column A, row number is 0. For column Z, row number is 25. After column Z, it again starts like AA, AB, AC...Write program to get the column name based on a number. The method should take any number and return the column name corresponding to that.  

  • Write a program to get an int value as argument and return it as string. For example, if I give the number 3456 as int, it should return the same number 3456 but as an object of String. You cannot use Java API methods.

  • You have an array of int with different numbers. You have to sort it in a way that the all the even numbers should come in the starting and odd numbers in the end. You cannot use a temp array or extra array in your solution.  

It was telephonic first round.purely technical based on oops concepts in depth.algo questions based on string are asked.Composition vs aggregation ,overloading vs overriding questions were not straight forward interviewer tried to confuse.


1. Write a function to reverse a string.

2. What’s the difference between Interface and Abstract.

3. Write a function to reverse words in a string

ex: “how are you” becomes “you are how”.

4. Can you assign a String to an Object? What about the other way around and why?

5. Explain Generics.

6. Explain Generics wildcardst.

7. Find the depth of a binary tree.

8. How can you run one thread and then another only after the first thread has completed? join()

9. What’s the difference between a thread sleep() and wait()? What about suspend(), resume()?

10. Write a function that traverses an array and checks the sum to the left of the index with the sum to the write of the index, and returns the index position when the left summation equals the right. Can you optimize your solution further?

11. Write an iterator that traverses an array of integers, but only for even values.

12. Design a library containing books with users that can check out books from the library.

This task is to meant to demonstrate your design abilities.  


Why String class is specific in Java?

Compare threads behavior in single processor-multiple core and multiple processor-single core systems?

Compare StringBuffer and StringReader!

And one tricky logical exercise.  


- Phone interview with a guy from England for an hour, including technical and brain teasing questions.

- Phone interview with a manager from New York for an hour and a half regarding my background

- In office interview with a panel of developers, including code writing and algorithms.

- In office interview for 4 hours with multiple persons, but I was out of the run after 2 hours.

The whole process lasted about a month with 2 weeks between the 3rd and the 4th. During those 2 weeks I lost my focus and was unprepared. So I failed to answer questions which I was able to answer before.


database: describe the 1NF, 2NF and 3NF.  


What is the difference between JDK 1.5 and JDK 1.4;

What is the HashCode and Equal method;

Talk about the database;

What is index, the advantage and disadvantage;

Why you leave current company?


  • How would you design <complex thing>  

  • If you inherited a legacy system with no documentation, how would you figure out what it does so that it could be replaced  

  • If you were working on a highly regulated project, how would you enforce the rules?  


1.How hashmap is stored?

2. why Hashmap is not thread safe. Whether I can use Hashmap in multi threaded environment

3. Flow of client - Server communication ( you can explain with Spring/Rest).  


When does a java static class get loaded/intialized by jvm?

http://javarevisited.blogspot.co.uk/2012/07/when-class-loading-initialization-java-example.html


write java programs on whiteboard for multi-threading, binary search, file processing


Write java program to perform a money transfer operation for a bank, which is multi-threaded and can run parallel with multi-processor machines  


GC strategies in the JVM  


basics of core java, webservices, designing concepts etc. Face to face interview s covered current project architecture, problem solving etc


What is the difference between SOAP and REST?

https://stackoverflow.com/questions/19884295/ soap-vs-rest-differences

What are the types of Garbage collectors?

http://javapapers.com/java/types-of-java-garbage-collectors/

How do you manage session details of the recent 10 most active users? Which are the collections you use for this?


1. Difference between Iterator and for loop

https://stackoverflow.com/questions/18508786/for-each-vs-iterator-which-will-be-the-better-option

2. Order of execution of static class level blocks, class level block and constructor.

http://javabeginnerstutorial.com/learn-by-example-3/order-of-execution-of-blocks-in-java/

3. Which is better interface or 100% Abstract Class and why?

4. Return statement in try, catch and finally. Which one executes when an exception occurs and what happens to the exception?

https://stackoverflow.com/questions/15225819/try-catch-finally-return-clarification

5. Something about Abstract class constructor.

6. Something about Cloneable Interface.


Generics

http://www.baeldung.com/java-generics-interview-questions


Distributed Cache

http://blog.gainlo.co/index.php/2016/05/17/design-a-cache-system/


Network Protocols

http://www.careerride.com/Interview-Questions-Protocols.aspx


https://career.guru99.com/top-100-networking-interview-questions-answers/


Operating Systems

https://career.guru99.com/top-50-operating-system-interview-questions/


http://www.geeksforgeeks.org/commonly-asked-operating-systems-interview-questions-set-1/

https://career.guru99.com/top-50-operating-system-interview-questions/

https://www.indiabix.com/technical/operating-systems/

http://www.geeksforgeeks.org/last-minute-notes-operating-systems/

http://www.geeksforgeeks.org/operating-system-paging/


Oops concept, Visualization, Paging, how inheritance works, algo to remove duplicate in LL, algo to detect loop in LL.


Hadoop

https://intellipaat.com/interview-question/big-data-hadoop-interview-questions/


Technical had standard questions like Second Minimum, BST Traversal/ Deletion, Heaps,

OS(Virtual Memory, Paging, Segmentation, semaphores)


Tree Node Deletion

http://www.algolist.net/Data_structures/Binary_search_tree/Removal


Java Concurrency

http://shazsterblog.blogspot.co.uk/2011/12/comparison-of-countdownlatch.html

https://stackoverflow.com/questions/4168772/java-concurrency-countdown-latch-vs-cyclic-barrier

http://blog.csdn.net/mrxiky/article/details/56675839

http://www.kuqin.com/shuoit/20151224/349628.html


A semaphore initialized to one, and which is used such that it only has at most one permit available, can serve as a mutual exclusion lock. This is more commonly known as a binary semaphore, because it only has two states: one permit available, or zero permits available. When used in this way, the binary semaphore has the property (unlike many Lock implementations), that the "lock" can be released by a thread other than the owner (as semaphores have no notion of ownership). This can be useful in some specialized contexts, such as deadlock recovery.


CompletableFuture

http://www.baeldung.com/java-completablefuture


Type of indexes:

https://www.postgresql.org/docs/9.2/static/indexes-types.html

What db system I have used? What is a view (is it only for selecting data?) What are indexes and for what reason. https://stackoverflow.com/questions/2955459/what-is-an-index-in-sql


Java Threadpools vs Executor

http://javarevisited.blogspot.co.uk/2016/12/difference-between-thread-and-executor.html

http://javarevisited.blogspot.co.uk/2017/02/difference-between-executor-executorservice-and-executors-in-java.html


Executor is an interface, ExecutorService (also an interface) is the implementation of Executor. Executor only defines execute(runnable) while ExecutorService also defines submit(Callable/Runnable). Executors class provides factory methods to create different kinds of thread pools e.g. newSingleThreadExecutor() creates a thread pool of just one thread.


FutureTask represents a cancellable asynchronous computation in concurrent Java application. This class provides a base implementation of Future, with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation. The result can only be retrieved when the computation has completed; the get methods will block if the computation has not yet completed. A FutureTask object can be used to wrap a Callable or Runnable object. Since FutureTask also implements Runnable, it can be submitted to an Executor for execution.


Java Concurrency questions

http://javarevisited.blogspot.co.uk/2014/07/top-50-java-multithreading-interview-questions-answers.html#axzz4qaPAqSvO


BlockingQueue and Producer-Consumer Pattern

http://tutorials.jenkov.com/java-concurrency/blocking-queues.html

http://javarevisited.blogspot.co.uk/2012/02/producer-consumer-design-pattern-with.html

http://javarevisited.blogspot.co.uk/2015/06/java-lock-and-condition-example-producer-consumer.html

https://dzone.com/articles/java-concurrency-blocking-queu


ConcurrentHashMap multiple reads

http://javarevisited.blogspot.co.uk/2013/02/concurrenthashmap-in-java-example-tutorial-working.html


ReentrantLock vs synchronized

http://javarevisited.blogspot.co.uk/2013/03/reentrantlock-example-in-java-synchronized-difference-vs-lock.html


Avoid deadlock

http://javarevisited.blogspot.co.uk/2010/10/what-is-deadlock-in-java-how-to-fix-it.html


There is only a limited number of threads a process can create

https://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux


PriorityQueue

http://www.journaldev.com/1642/java-priority-queue-priorityqueue-example

http://www.eecs.wsu.edu/~ananth/CptS223/Lectures/heaps.pdf

natural order is asending order.



Comparable vs Comparator

http://www.journaldev.com/780/comparable-and-comparator-in-java-example

Comparable interface has compareTo(Object o) method while Comparator has compare(Object o1, Object o2)

 

转载于:https://www.cnblogs.com/codingforum/p/7451036.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值