Java Technology Lead

10+ Java Technology Lead Interview Questions and Answers

Updated 4 Apr 2022
Q1. Where are instance variables of an object stored in the JVM?
Ans.

Instance variables of an object in JVM are stored in the heap memory.

  • Instance variables are stored in the heap memory allocated for the object.

  • Each object has its own copy of instance variables.

  • Instance variables are accessed using object references.

Q2. What is the difference between the Factory and Abstract Factory design patterns?
Ans.

Factory pattern creates objects without exposing the instantiation logic, while Abstract Factory pattern provides an interface for creating families of related or dependent objects.

  • Factory pattern creates objects through a common interface, while Abstract Factory pattern creates families of related objects.

  • Factory pattern uses a single method to create objects, while Abstract Factory pattern uses multiple methods to create families of objects.

  • Factory pattern is a single metho...read more

Q3. How do you define 'many-to-many' relationship in Hibernate when there are no common columns between two tables?

Ans.

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. What is a marker interface in Java?
Ans.

A marker interface in Java is an interface with no methods, used to mark classes for special treatment.

  • Marker interfaces are used to provide metadata to the classes implementing them.

  • Examples of marker interfaces in Java include Serializable and Cloneable.

  • Marker interfaces are typically empty interfaces with no methods.

Are these interview questions helpful?

Q5. How do you find the second largest integer in an array without using collections or without sorting the array?

Ans.

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.

Q6. How does PUT method behave when there is no data to update?

Ans.

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

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. How do you make sure some default code executes when the Spring boot applications starts up?

Ans.

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

Q8. 1) How to communicate between two micro services?

Ans.

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

Java Technology Lead Jobs

Java Tech Lead 7-10 years
Applied Materials India Private Limited
3.9
Bangalore / Bengaluru
Java Tech Lead 8-12 years
Tech Mahindra
3.5
Pune
Java Tech Lead (Java & SpringBoot & React JS) 6-10 years
Oracle
3.7
₹ 15 L/yr - ₹ 23 L/yr
Mumbai

Q9. Whats the difference between @Service and @Component annotations?

Ans.

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

Q10. What is the architecture of Kubernetes?
Ans.

Kubernetes follows a client-server architecture with a master node and worker nodes.

  • Kubernetes architecture consists of a master node and multiple worker nodes.

  • The master node manages the cluster and schedules applications.

  • Worker nodes run the applications and communicate with the master node.

  • Kubernetes uses etcd for storing configuration data.

  • Components like kube-apiserver, kube-controller-manager, kube-scheduler, and kubelet are part of the architecture.

Q11. What does the HTTP error codes 400, 500 represent?

Ans.

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).

Q12. How does a concurrent Hash Map works internally?

Ans.

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

Q13. How do you define a composite Primary key?

Ans.

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.

Q14. What is an API Gateway?
Ans.

An API Gateway is a server that acts as an API front-end, receiving API requests, enforcing throttling and security policies, passing requests to the back-end services, and then passing the response back to the requester.

  • Acts as a single entry point for all API requests

  • Handles authentication, authorization, and rate limiting

  • Can transform requests and responses

  • May aggregate multiple back-end services into a single API endpoint

Q15. What are Kafka Streams?
Ans.

Kafka Streams is a client library for building real-time, highly scalable, fault-tolerant stream processing applications.

  • Kafka Streams allows developers to process and analyze data in real-time as it flows through Kafka topics.

  • It provides a high-level DSL for creating stream processing applications without the need for a separate processing cluster.

  • Kafka Streams supports stateful processing, windowing, and joins, making it suitable for a wide range of use cases.

  • Example: Using...read more

Q16. Difference between PUT and POST methods?

Ans.

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?

Ans.

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?

Ans.

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 Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.9
 • 410 Interviews
View all

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

Java Technology Lead Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter