Java & Spring experienced interview questions

Kiran Kumar
4 min readJan 29, 2022

--

In recent days , lateral hires are very high . so lets check out what are possible java experienced interview questions . This post

  1. Tell about yourself .
  2. What is the difference between string buffer and string builder?
  3. Where does the normal variables , objects store in memory ?
  4. Is java 100% OOP language ? Yes/NO ? How to do you prove it ?
  5. Why do we have difference memories like heap memory , stack memory, dynamic memory ?
  6. Why string is immutable ? in which memory does it store data?
  7. What is the difference between == and equals() method?
  8. how is the data stored in HashMap ?
  9. what is the difference between HashMap and HashTable?
  10. what is the difference between HashSet and TreeSet?
  11. can we extend class to interface ?
  12. how will you clone the object in java ? which interface is used ? which method is used for cloning ?
  13. What is the use of java streams ? why we should use streams ?
  14. why main function have public static void ? what does it mean?
  15. what is the difference between errors and exceptions ?
  16. what is difference between static and non-static context ?
  17. Can you name some synchronized collections ?
  18. Explain about your last three project , what work you have been doing ?
  19. What is difference between sleep and wait method in thread? which method is invoked once thread is in waiting state?
  20. What is the difference between hashcode() and equals() methods ?
  21. Answer below snippet

public void fun(){

static int a = 10;
System.out.println(a);
}

21. Answer below question

public void fun(){

try{

System.out..println(“try”)
int 1 = 9/0;
}
catch(arthemeticexception e){
System.out..println(“catch1”)
}
catch(exception e){
System.out..println(“catch2”)
}
finally{
System.out..println(“finally”)
{
}

21. why we do create private constructor in class?

22. why C/C++ program return int , but not Java?

Spring Questions :

  1. what is the difference between @Controller and @RestController ?
  2. what is the @Transaction in spring ?
  3. what is the use of @ControllerAdvice in spring ?
  4. what is the difference between spring MVC and Spring boot ?
  5. What is the use of @SpringBootApplication ?
  6. What is Springboot Actuator ?
  7. How do you communicate between services in two different boot services?
  8. Can we have two @ControllerAdvice in one project ?
  9. What are the propogations and ISOLATION levels do you know in spring ?
  10. Spring boot vs SPRING framework
  11. what is @Qualifier used for in spring?
  12. what is the difference between constructor injection vs field injection ? which one do you prefer why explain ?

Microservices:

  1. How will you make sure transactions are completed or rollbacked when two microservices talking to each other ?
  2. How will make sure microservice is always be available without any downtime?
  3. What is strangler design pattern ?
  4. explain decorator design pattern?
  5. How will you communicate between microservices ?
  6. REST Template vs FEIGN client ?
  7. What is service registry ? What is the use of service registry?
  8. What are the advantages and disadvantage of microservices?
  9. How do you handle transaction rollback between two/three microservices?
  10. what are microservices principles ? how it is different from SOLID principles ?

CICD:

  1. Which CICD tool do you know ?
  2. Are you aware of Kubernetes and Docker ? What is the difference between them ?
  3. What is the deployment strategy of your project ?

Caching mechanism:

  1. What is ehcache? How do you implement it ?
  2. We can talk about Redis cache , if you know about it every well.

Threads :

  1. what if multiple thread accessing the same service at a time ? how to avoid congestion in this situation?
  2. Write a program to thread prints even numbers and another thread with odd numbers ? What happens if its synchronization is implemented with this scenario ?
  3. What is the difference between runnable and callable in thread?

Hibernate

  1. what is the use of @Lazy and @Eager in hibernate ?
  2. what are the design patterns used in hibernate framework?
  3. How to enable the second level cache ?

SQL Interview questions:

  1. What is View in POSTGRESQL | Materialized View in POSTGRESQL | Refresh Materialized view | SQL Views?
  2. What is difference between vertical partitioning vs horizontal partitioning in database ?
  3. how many types of indexes are there ? What are they ? When to use what? is indexing DBA Job or Developer job?
  4. What is the best way to modify the existing composite key in SQL?
  5. consider if any update is taking time , what are the consequences which is causing performance issue? how can you avoid it ?
  6. what is the difference between count(*) and count(1) can you explain?
  7. How to do you find second highest salary of the employee?https://www.youtube.com/watch?v=OgKDjlzTWRU

Best Practices in Java:

Serialization in Java

Other useful links :

--

--

Kiran Kumar

Technophile with 10 years experience in IT industry | Java Lead cum Architect