Java & Spring experienced interview questions
In recent days , lateral hires are very high . so lets check out what are possible java experienced interview questions . This post
- Tell about yourself .
- What is the difference between string buffer and string builder?
- Where does the normal variables , objects store in memory ?
- Is java 100% OOP language ? Yes/NO ? How to do you prove it ?
- Why do we have difference memories like heap memory , stack memory, dynamic memory ?
- Why string is immutable ? in which memory does it store data?
- What is the difference between == and equals() method?
- how is the data stored in HashMap ?
- what is the difference between HashMap and HashTable?
- what is the difference between HashSet and TreeSet?
- can we extend class to interface ?
- how will you clone the object in java ? which interface is used ? which method is used for cloning ?
- What is the use of java streams ? why we should use streams ?
- why main function have public static void ? what does it mean?
- what is the difference between errors and exceptions ?
- what is difference between static and non-static context ?
- Can you name some synchronized collections ?
- Explain about your last three project , what work you have been doing ?
- What is difference between sleep and wait method in thread? which method is invoked once thread is in waiting state?
- What is the difference between hashcode() and equals() methods ?
- 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 :
- what is the difference between @Controller and @RestController ?
- what is the @Transaction in spring ?
- what is the use of @ControllerAdvice in spring ?
- what is the difference between spring MVC and Spring boot ?
- What is the use of @SpringBootApplication ?
- What is Springboot Actuator ?
- How do you communicate between services in two different boot services?
- Can we have two @ControllerAdvice in one project ?
- What are the propogations and ISOLATION levels do you know in spring ?
- Spring boot vs SPRING framework
- what is @Qualifier used for in spring?
- what is the difference between constructor injection vs field injection ? which one do you prefer why explain ?
Microservices:
- How will you make sure transactions are completed or rollbacked when two microservices talking to each other ?
- How will make sure microservice is always be available without any downtime?
- What is strangler design pattern ?
- explain decorator design pattern?
- How will you communicate between microservices ?
- REST Template vs FEIGN client ?
- What is service registry ? What is the use of service registry?
- What are the advantages and disadvantage of microservices?
- How do you handle transaction rollback between two/three microservices?
- what are microservices principles ? how it is different from SOLID principles ?
CICD:
- Which CICD tool do you know ?
- Are you aware of Kubernetes and Docker ? What is the difference between them ?
- What is the deployment strategy of your project ?
Caching mechanism:
- What is ehcache? How do you implement it ?
- We can talk about Redis cache , if you know about it every well.
Threads :
- what if multiple thread accessing the same service at a time ? how to avoid congestion in this situation?
- Write a program to thread prints even numbers and another thread with odd numbers ? What happens if its synchronization is implemented with this scenario ?
- What is the difference between runnable and callable in thread?
Hibernate
- what is the use of @Lazy and @Eager in hibernate ?
- what are the design patterns used in hibernate framework?
- How to enable the second level cache ?
SQL Interview questions:
- What is View in POSTGRESQL | Materialized View in POSTGRESQL | Refresh Materialized view | SQL Views?
- What is difference between vertical partitioning vs horizontal partitioning in database ?
- how many types of indexes are there ? What are they ? When to use what? is indexing DBA Job or Developer job?
- What is the best way to modify the existing composite key in SQL?
- consider if any update is taking time , what are the consequences which is causing performance issue? how can you avoid it ?
- what is the difference between count(*) and count(1) can you explain?
- How to do you find second highest salary of the employee?https://www.youtube.com/watch?v=OgKDjlzTWRU
Best Practices in Java: