Java Questions

As I mentioned that I have attended almost more than 50 interviews in companies like Goldman Sachs, JP Morgan, Citibank, Barclays Bank, UBS, DBS, Broadridge, CA Technologies etc. Although I gave interview on JAVA and UI both but all were mainly in JAVA. I am putting few question based on my memory which will help everyone to get the flavor of current market interview questions. Here I am going to cover Core Java, Spring Framework, Hibernate and Rest Web Services. I am not going to post answers, it would be better, if it has to be found on own. 

Core Java

  1. Define OOPS concept.
  2. I am novice in JAVA, make me understand Abstraction, Encapsulation and Polymorphism with real-time examples.
  3. What do you feel good/special about String in Java?
  4. What is String pool?
  5. Explain the status of string pool in following scenarios:
    • String s1 = “abc”;
    • String s2 = s1;
    • String s3 = new String(“abc”);
    • String s4 = s3;
    • String s5 = “abc”;
  6. What is the difference between “==” and equal method?
  7. What is dead lock in multithreading and how to prevent it?
  8. Write a program for palandrome? They are asking more on optimization.
  9. Write a program to find nth repeated character in a string.
  10. What is Singleton Pattern? Write Singleton class in thread safe, lazy loading and double checked way.
  11. What is Generics. What is use of it? Can we write our own generics?
  12. What is Blocking Queue, Explain with example.
  13. What is Hashmap, Explain its functionality. What is data structure of Hashmap? (most important question)
  14. What is LinkedList and ArrayList? what is the difference and in which scenario what would be used?
  15. What is Serialization and Deserialization? Explain with example.
  16. What is the default size of Arraylist and how resizing happens?
  17. What is difference between Array and Arraylist?
  18. Write internal architecture of Arraylist class.
  19. What is Interface? Difference between Interface and Abstract?
  20. How to iterate Hashmap? Write a program where Key is object and value is string.
  21. Explain how can we restrict duplicate values in Hashmap when Key is object
    • map.put(new(1,”abc”), “Hello”);
    • map.put(new(2.”pqr”), “Welcome”);
    • map.put(new(1,”abc”), “Hello”);
  22. What would be best algorithm of encryption and decryption of a file which has characters and numbers?
  23. which is the best collection to read million records data?
  24. How to access private method in other class?
  25. Explain types of Exception? If answered then what is Checked and Unchecked exception?
  26. Can we execute any class without main method, if yes how? (This is very tricky question)
  27. Write a program to reverse the Arraylist objects.
  28. Write a program to find maximum number in integer array.
  29. What is Override and Overloading? Explain with example.
  30. Write a program to convert string to Integer or Integer to string without using valueOf or parseInt.
  31. What is garbage collection? How to use it?
  32. What is Out of Memory exception. How to prevent it short-term and long-term basis?
  33.  What is difference between Custom Exception, Runtime Exception.
  34. What are new features in Java 8, what code changes are required to migrate to java 8.
  35. What is Try-with catch introduced in Java 7.
  36. How many version of jdk you worked on, explain difference or new features introduced in each version.
  37. Can you explain System.out.println(“Hello World”) in terms of java?
  38. In Overriding, if we have two methods, one has return type string and other is object with the same method structure get. If we call get(null) which method would be called and why?

Spring Framework

  1. What is Spring IoC (Inversion of Control)?
  2. Explain Dependency Injection with example. (Must question)
  3. What is Aspect Oriented Programming?
  4. What are different types of bean scopes? What is default scope? (Very Important question)
  5. What is Singleton bean scope explain with example? 
  6. Write Singleton class and how to access it?
  7. What is prototype scope. Explain with example
  8. What are different types of context?
  9. Explain about the annotations used in your spring based application
  10. What is difference between @controller and @restcontroller?
  11. What is use of @service annotation? can we have any application without this
  12. What is default servlet in Spring MVC framework?
  13. Explain bean life cycle.
  14. Explain Spring MVC architecture. (Important Question)
  15. Have you worked on Spring boot?
  16. Explain different Spring module used.
  17. What is singleton scope in spring? Can we define two beans for singleton?
  18. How to break singleton pattern?

Rest Web-Services

  1. How to set parameters in Rest Call?
  2. How to set content type in produce or consume rest web-services?
  3. If we want to consume different content-types using one method, how can we achieve it?
  4. How to authorize and authenticate Web-services?
  5. What are the HTTP verbs available in Rest Web-services?
  6. Why REST is called Stateless? Elaborate with example.
  7. How to call web-service from application to application?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s