Java Technology Lead
10+ Java Technology Lead Interview Questions and Answers
Q2. How do you define 'many-to-many' relationship in Hibernate when there are no common columns between two tables?
Many-to-many relationship in Hibernate without common columns
Create a third table with foreign keys to both tables
Use @ManyToMany annotation in both entity classes
Specify the join table name and column names in @JoinTable annotation
Q4. How do you find the second largest integer in an array without using collections or without sorting the array?
Find second largest integer in an array without sorting or using collections.
Iterate through array and keep track of largest and second largest integers.
Compare each element with current largest and second largest integers.
Return second largest integer.
Share interview questions and help millions of jobseekers 🌟
Q7. How does PUT method behave when there is no data to update?
PUT method updates data if available, else returns success with no changes.
PUT method updates the resource if it exists, else creates a new resource
If no data is provided, the server returns a success response with no changes made
Example: PUT /users/1 with empty body will return success with no changes if user with id 1 exists
Java Technology Lead Jobs
Q9. How do you make sure some default code executes when the Spring boot applications starts up?
Use @PostConstruct annotation or implement CommandLineRunner interface
Use @PostConstruct annotation on a method that needs to be executed on startup
Implement CommandLineRunner interface and override run() method
Add the code that needs to be executed on startup in the method annotated with @PostConstruct or in the run() method
Example: @PostConstruct public void init() { //code to be executed on startup }
Example: public class MyApp implements CommandLineRunner { public void run...read more
Q10. 1) How to communicate between two micro services?
Microservices can communicate through synchronous or asynchronous protocols like REST, gRPC, or message brokers.
Use RESTful APIs for synchronous communication
Use message brokers like Kafka or RabbitMQ for asynchronous communication
gRPC can be used for high-performance synchronous communication
API Gateway can be used to manage communication between microservices
Consider using service mesh like Istio or Linkerd for more advanced communication needs
Q11. Whats the difference between @Service and @Component annotations?
The @Service annotation is a specialization of the @Component annotation and is used to indicate that a class is a service.
Both @Service and @Component annotations are used to indicate that a class is a Spring-managed component.
@Service is a specialization of @Component and is used to indicate that a class is a service layer component.
The @Service annotation is used to add a layer of abstraction between the controller and the DAO layer.
The @Service annotation is used to provi...read more
Q13. What does the HTTP error codes 400, 500 represent?
HTTP error codes 400 and 500 represent client and server errors respectively.
HTTP error code 400 indicates a client-side error, such as a bad request or invalid input.
HTTP error code 500 indicates a server-side error, such as an internal server error or database connection issue.
Other common client-side errors include 401 (unauthorized), 403 (forbidden), and 404 (not found).
Other common server-side errors include 503 (service unavailable) and 504 (gateway timeout).
Q14. How does a concurrent Hash Map works internally?
Concurrent Hash Map is a thread-safe implementation of Hash Map.
Uses multiple segments to allow concurrent access
Each segment is a separate hash table with its own lock
Segments are dynamically added or removed based on usage
Uses CAS (Compare and Swap) operation for updates
Provides higher concurrency than synchronized Hash Map
Q15. How do you define a composite Primary key?
A composite primary key is a primary key that consists of two or more columns.
A composite primary key is used when a single column cannot uniquely identify a record.
It is created by combining two or more columns that together uniquely identify a record.
Each column in a composite primary key must be unique and not null.
Example: A table of orders may have a composite primary key consisting of order number and customer ID.
Q16. Difference between PUT and POST methods?
PUT is used to update an existing resource while POST is used to create a new resource.
PUT is idempotent, meaning multiple identical requests will have the same effect as a single request.
POST is not idempotent and can result in multiple resources being created if the request is sent multiple times.
PUT requires the client to send the entire updated resource while POST only requires the necessary fields to create a new resource.
PUT is typically used for updating data while POS...read more
Q17. 2)What are SOLID principles?
SOLID principles are a set of five design principles for writing maintainable and scalable code.
S - Single Responsibility Principle: A class should have only one reason to change.
O - Open/Closed Principle: Software entities should be open for extension but closed for modification.
L - Liskov Substitution Principle: Subtypes should be substitutable for their base types.
I - Interface Segregation Principle: Clients should not be forced to depend on interfaces they do not use.
D - ...read more
Q18. Explain Microservices design pattern?
Microservices is a design pattern where an application is broken down into small, independent services that communicate with each other.
Each service is responsible for a specific task or feature
Services communicate with each other through APIs
Each service can be developed, deployed, and scaled independently
Allows for greater flexibility, agility, and resilience
Requires a strong focus on automation, monitoring, and testing
Interview Questions of Similar Designations
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month