Morgan Stanley Java Interview Questions


  1. What is the difference between abstraction and polymorphism?
  2. What is encapsulation?
  3. How to print repeated no. stored in an array? using hash Set , using Hashmap
  4. How to swap to string without using third variable ?

public class SwapToString {

public static void main(String[] args) {
// TODO Auto-generated method stub
 String a="Hellow";
String b="World";
System.out.println("String before swap   "  + a+ "   "+b);
a=a+b;
b=a.substring(0,a.length()-b.length() );
System.out.println(b);
System.out.println(a);
System.out.println(a.substring(b.length()));


}

}
-----------------------
o/p
String before swap   Hellow   World
Hellow
HellowWorld
World

  1. what and all design pattern you have worked on?
  2. What is factory design pattern ?
  3. What is singleton design pattern ?
  4. How do you create your own singleton class ?
  5. How do you create your own immutable class?
  6. Why is String immutable?
  7. What is the difference between String a="abc"; and String a = new String("abc");
  8. what is intern in string ?
  9.  what are the memory structure in java?
  10. where does SCP belongs , which memory area?
  11. how many objects (String) are getting created in the question 11?
  12. what is the significance of each key word in case of your own implemented immutable and singleton class like final , static etc?
  13. What happens when you override static method in java?
  14. What is overriding and overloading in java?
  15. What happens when you try to overload a method only by changing the return type?
  16. what is metadata and premgem in java?
  17. How to make singleton class in case of multithreading environment ?
  18. How does synchronized work in java ?
  19. How does internally hashMap works?
  20. Is it good if you want to use a large no of bucket in hashMap?
  21. What and all collections have you used ?
  22. What is the difference between ArrayList and LinkedList?
  23. When to use arrayList and linkedList ?
  24. What and all you need to keep in mind if you are creating a hasMap with key as Employee and value any thing else ?:- Here key must be immutable and need to override equals and hascode?
  25. What is the contract between equal and Hashcode ?
  26. Have you worked on java 8?

Comments

Popular posts from this blog

Java Memory interview qustions

Skills to become a java developer