July 27, 2019

Morgan Stanley Java Interview Questions

  1. What is a predicate in Java? Can you throw an exception from a predicate? Its a functional interface which accept one argument and produce a result. (solution
  2. Explain fail fast and fail safe iterators. (solution)
  3. Implement stack using Queue.(solution)
  4. Write a program to reverse a linked list. (solution)
  5. Write a program to return all characters from a string which appeared more than once. (solution)
  6. Generate the Fibonacci recursively and iteratively in Java. Explain the complexities for both solutions.(solution)
  7. Swap the values between two elements without using a third element.
  8. Generate all anagrams of a String.(solution)
  9. How PriorityQueue works internally in Java?
  10. Difference between TreeSet and PriorityQueue in Java.
  11. Given a string like ABC find all possible distinct permutations, e.g:ABC,BAC,CAB etc.
  12. Sort array elements in place making even and odd number together.
  13. Write a function to return the maximum difference between two elements in an array.
  14. I have an array of million integers. I want to sum it efficiently. How would you do it without using Java 8 parallel streams? (Hint: use forkjoinpool)
  15. Some Basic Core Java Interview Questions related to Polymorphism and try catch(solution)
  16. Write a method to find the first non-repeating character from a String? (solution)
  17. We have a balanced Binary Tree, am trying to throw a light from a particular node, which all nodes will be visible?(solution)
  18. What will happen if we return a constant number from overriden hashCode() method?
  19. What will happen if we return constant number from overriden hashCode() method and false from equals()?
  20. What will happen if we return constant number from overriden hashCode() method and true from equals()?

No comments:

Post a Comment