Java Technical Lead
20+ Java Technical Lead Interview Questions and Answers
Q1. Internals of JVM. Where is class , variables , objects stored in JVM
Classes, variables, and objects are stored in different areas of JVM's memory.
Classes are stored in the method area of JVM's memory.
Variables are stored in the stack or heap depending on their scope and lifetime.
Objects are stored in the heap area of JVM's memory.
Static variables are stored in the method area.
Local variables are stored in the stack.
Instance variables are stored in the heap.
Primitive data types are stored in the stack.
References to objects are stored in the st...read more
Q2. Exceptions code snippets to guess output. How to convert checked exception to unchecked exception
To convert checked exception to unchecked exception, use RuntimeException or create a custom unchecked exception.
Use RuntimeException to wrap checked exceptions and throw them as unchecked exceptions
Create a custom unchecked exception by extending RuntimeException class
Use try-catch block to catch checked exceptions and throw them as unchecked exceptions
Q3. What is streams and how to get distinct objects Whats are conventions we follow for rest api Spring mvc error handling and spring boot configuration annotations
Streams in Java and conventions for REST API. Spring MVC error handling and Spring Boot configuration annotations.
Streams are a sequence of elements that can be processed in parallel or sequentially.
To get distinct objects, use the distinct() method.
Conventions for REST API include using HTTP methods, status codes, and resource naming.
Spring MVC error handling can be done using @ExceptionHandler annotation.
Spring Boot configuration annotations include @Configuration, @EnableA...read more
Q4. what is the difference between stream and parallel stream
Stream is sequential while parallel stream is concurrent
Stream is a sequence of elements that can be processed sequentially
Parallel stream is a sequence of elements that can be processed concurrently
Parallel stream can improve performance for large datasets
Parallel stream uses multiple threads to process elements in parallel
Stream is suitable for small datasets or when order of processing is important
Q5. Design patterns used in Microservice architecture. API Gateway
Design patterns like API Gateway, Circuit Breaker, Service Registry, and Service Discovery are commonly used in Microservice architecture.
API Gateway pattern is used to provide a single entry point for all clients to access the microservices.
Circuit Breaker pattern is used to prevent cascading failures in microservices.
Service Registry pattern is used to keep track of all the available services in the microservice architecture.
Service Discovery pattern is used to locate the a...read more
Q6. Why we need 2 way SSL?
2 way SSL is needed for mutual authentication between client and server.
2 way SSL ensures that both client and server are authenticated
It provides an extra layer of security by verifying the identity of both parties
It is commonly used in financial transactions, healthcare, and government applications
Share interview questions and help millions of jobseekers 🌟
Q7. What is the Controller Advice?
Controller Advice is a mechanism in Spring MVC to handle exceptions globally.
It is used to handle exceptions across multiple controllers.
It can be used to add common data to the model.
It can be used to customize the response status code and message.
It can be used to redirect to a custom error page.
Q8. How to group by in streams
Grouping by in streams in Java
Use the 'groupingBy' method from the 'Collectors' class
Pass a lambda expression to specify the grouping criteria
The result is a Map with the grouping criteria as keys and the grouped elements as values
Java Technical Lead Jobs
Q9. What is Decorator design pattern
Decorator pattern adds behavior to an object dynamically without affecting its existing behavior.
It is a structural pattern
It involves a component interface, concrete component, decorator interface, and concrete decorator
Decorators wrap around components to add new behavior
It allows for flexible and dynamic behavior modification
Example: Java I/O streams use decorator pattern
Q10. What is marker interface
A marker interface is an interface with no methods used to mark a class as having a certain property or behavior.
Marker interfaces are used to provide metadata about a class.
They are often used in frameworks and libraries to indicate that a class should be treated in a certain way.
Examples include Serializable, Cloneable, and Remote interfaces in Java.
Marker interfaces can also be used to enforce design patterns, such as the Decorator pattern.
Marker interfaces are different f...read more
Q11. Usage of Kafka and Kafka Streams
Kafka is a distributed streaming platform used for building real-time data pipelines and streaming applications.
Kafka is used for building real-time data pipelines and streaming applications
Kafka Streams is a client library for building applications and microservices that process streams of data
Kafka provides fault-tolerant storage and processing of streams of records
Kafka Streams allows for stateful and stateless processing of data
Kafka can be used for various use cases such...read more
Q12. Find occurance of each element of an array using Streams API
Using Streams API to find occurrence of each element in an array of strings
Use Arrays.stream() to convert the array to a stream
Use Collectors.groupingBy() to group elements by their occurrences
Use Collectors.counting() to count the occurrences of each element
Q13. what are the idempotent methods in REST API call
Idempotent methods in REST API calls are operations that can be repeated multiple times without changing the result beyond the initial application.
GET method is idempotent as it retrieves data and does not change the state of the server
PUT and DELETE methods are also idempotent as they perform the same operation regardless of how many times they are called
POST method is not idempotent as it creates a new resource each time it is called
Q14. what are java 8 new features
Java 8 introduced lambda expressions, streams, default methods, and more.
Lambda expressions for functional programming
Streams for efficient processing of large data sets
Default methods to add new functionality to existing interfaces
Date and Time API for improved handling of date and time
Optional class to avoid null pointer exceptions
Nashorn JavaScript engine for improved performance
Parallel array sorting for faster sorting of large arrays
Q15. how we can improve microservice security
Improving microservice security involves implementing authentication, authorization, encryption, and monitoring.
Implement strong authentication mechanisms such as OAuth or JWT
Use role-based access control for authorization
Encrypt sensitive data in transit and at rest
Implement monitoring and logging to detect and respond to security incidents
Q16. Sort strings on the basis of city.
Sort strings based on city names.
Use Arrays.sort() method with a custom Comparator to sort strings based on city names.
Create a Comparator that compares the city names of two strings.
Example: String[] cities = {"New York", "London", "Paris"};
Example: Arrays.sort(cities, (a, b) -> a.compareTo(b));
Q17. Difference between PUT and POST
PUT is used to update or replace 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, meaning multiple identical requests may have different effects.
PUT is used when the client knows the URI of the resource it wants to update.
POST is used when the client does not know the URI of the resource it wants to create.
Q18. Microservices with Kubernate deployment
Microservices with Kubernate deployment involves breaking down an application into smaller, independent services and deploying them using Kubernetes.
Microservices architecture involves breaking down a monolithic application into smaller, independent services that can be developed, deployed, and scaled independently.
Kubernetes is a container orchestration platform that automates the deployment, scaling, and management of containerized applications.
Deploying microservices with ...read more
Q19. Find 2nd max element.
Find 2nd max element in an array of strings.
Sort the array in descending order
Return the element at index 1
Q20. Use of static in main function
Using static in main function allows it to be called without creating an instance of the class.
Static in main function allows it to be called directly without creating an object of the class.
Static methods can be called using the class name itself, without creating an object.
Example: public static void main(String[] args) { }
Q21. Internal working of HashMap?
HashMap is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values.
HashMap internally uses an array of linked lists to store key-value pairs.
When a key-value pair is added, the key is hashed to find the index in the array where it will be stored.
If multiple keys hash to the same index, a linked list is used to handle collisions.
Retrieving a value involves hashing the key to find the index and then traversing the linked list to find the val...read more
Interview Questions of Similar Designations
Interview experiences of popular companies
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