0% found this document useful (0 votes)
105 views2 pages

Deloitte Java Developer Interview Guide

The document outlines a series of interview questions related to Spring Boot, caching, microservices, Java core concepts, and SQL. It covers topics such as handling multiple beans, custom annotations, inter-service communication, OOP principles, and database indexing. This comprehensive list serves as a preparation guide for candidates interviewing for positions requiring knowledge in these areas.

Uploaded by

saiakshaykv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views2 pages

Deloitte Java Developer Interview Guide

The document outlines a series of interview questions related to Spring Boot, caching, microservices, Java core concepts, and SQL. It covers topics such as handling multiple beans, custom annotations, inter-service communication, OOP principles, and database indexing. This comprehensive list serves as a preparation guide for candidates interviewing for positions requiring knowledge in these areas.

Uploaded by

saiakshaykv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Deloitte Interview Experience

✅ Spring & Spring Boot


1.​ How to handle multiple beans of the same type in Spring Boot?​

2.​ How do we create custom annotations in Spring Boot?​

3.​ How can we customize specific auto-configuration in Spring Boot?​

4.​ What are the different scopes available in Spring Boot?​

5.​ How can we create a custom scope in Spring?​

✅ Caching
6.​ What is caching in Spring Boot? How do you implement it?​

✅ Microservices
7.​ How does inter-service communication work in microservices?​

8.​ What are the differences between Service Registry and Service Discovery?​

9.​ What is the Saga Design Pattern?​

10.​What is idempotency in microservices?​


✅ Java Core
11.​What is the superclass of all Java classes? What are some key methods?​

12.​How can a single class (like class A) demonstrate OOP principles?​

13.​What is the difference between ArrayList and LinkedList?​

14.​What is the difference between HashMap and ConcurrentHashMap?​

15.​Which collection would you use to remove duplicates while maintaining insertion order?​

16.​What is the volatile keyword in Java?​

17.​What is the transient keyword in Java?​

18.​Differences between StringBuilder and StringBuffer​

19.​Differences between == and .equals() in Java​

✅ SQL
20.​What is an index and how do you create it in SQL?​

21.​How does indexing work internally (B-Tree, Hash, Clustered vs Non-Clustered)?

Common questions

Powered by AI

In Spring Boot, custom annotations can be created by defining a new annotation interface using the @interface keyword and applying relevant meta-annotations such as @Retention and @Target to specify its scope and applicable elements. Custom annotations are practical for simplifying the application code, ensuring consistent configurations, and providing reusable behavioral patterns across multiple classes or methods. For instance, they can be used to enforce security checks, validate input, or apply specific logging configurations across various components in a modular way .

The volatile keyword in Java indicates that a variable's value will be modified by different threads. By declaring a variable volatile, developers instruct the JVM to always read the variable's value from main memory and not cache it in thread-local storage. This ensures visibility of changes to the variable across threads, addressing a key issue in concurrent programming where threads might work with outdated copies of variables. While volatile ensures visibility, it does not provide atomicity, therefore, it should be used wisely in scenarios where only visibility of states across threads is crucial .

The Saga Design Pattern is used to manage transactions across multiple services in a microservices architecture. Instead of using a traditional, centralized transaction, the saga pattern implements a sequence of local transactions. Each transaction publishes an event that triggers the next transaction in the saga. If one step fails, the saga executes compensating transactions to undo the work performed by preceding transactions. This approach ensures data consistency without needing distributed locks, thus handling transactions in a reliable way across distributed systems .

Idempotency in microservices refers to the property of certain operations where the operation can be applied multiple times without changing the result beyond the initial application. This is significant in distributed systems where operations might need to be retried due to failures, ensuring that repeated execution doesn't adversely affect the system state. For instance, if a service receives a request to change the price of a product, an idempotent design ensures that multiple identical requests do not lead to incorrect data updates or inconsistent states across the system .

In Spring Boot, multiple beans of the same type can be handled using the @Primary annotation or by applying Qualifiers. The @Primary annotation marks one bean as the default candidate to autowire when there are multiple beans of the same type available. Alternatively, the @Qualifier annotation can be used to specify exactly which bean should be autowired by matching with the bean's qualifier value, allowing explicit designation in cases where multiple beans are present .

Inter-service communication strategies in microservices include REST, gRPC, and message brokers like RabbitMQ or Kafka. REST is simple to implement and HTTP-based but can be limiting for real-time applications due to its synchronous nature. gRPC provides high performance through HTTP/2 and binary data serialization, suitable for services that require low latency, but it can be complex to set up. Message brokers offer asynchronous communication, ensuring loose coupling, reliability, and scalability, but can introduce latency and require additional infrastructure for managing message queues .

Indexes in SQL databases are data structures that improve the speed of data retrieval operations on a database table at the cost of additional storage and increased maintenance time when inserting or updating data. They work by providing a shortcut to data, reducing the amount of data the database system needs to scan when executing a query. Common implementations include B-Tree for range queries and Hash Indexes for equality comparisons. Properly using indexes can greatly enhance query performance by allowing faster access to the data but require careful management to avoid slowdowns associated with index maintenance .

ArrayList and LinkedList differ significantly in their internal implementation and performance characteristics. ArrayList uses a dynamic array to store elements, leading to O(1) time complexity for access operations but potentially costly O(n) insertions and deletions, as elements might need to be shifted. LinkedList, however, employs a doubly-linked list structure, leading to O(n) access time but more efficient O(1) insertions and deletions when the position is known. ArrayList is preferred when frequent access or iteration over a list is needed, whereas LinkedList is better suited for cases involving frequent list mutation such as adding or removing elements from the list .

Customizing auto-configuration in Spring Boot is significant as it allows developers to tailor the framework's default behaviors and settings to fit specific application needs, thus enhancing flexibility and functionality. This customization can be achieved through condition evaluation using annotations like @ConditionalOnProperty or by providing custom configurations that override the default bean definitions. By doing so, developers can fine-tune the application’s configuration, disable unwanted auto-configured beans, and implement additional custom beans as needed without direct modifications to Spring Boot's source code .

HashMap is not synchronized and is not thread-safe, which means if multiple threads access a HashMap concurrently and one of the threads modifies the structure of the map, it must be externally synchronized. ConcurrentHashMap, on the other hand, is a thread-safe variant that allows concurrent read and write operations without the need for explicit synchronization. Performance-wise, ConcurrentHashMap uses a finer-grained locking mechanism called lock striping, which reduces contention and improves concurrency compared to the single-thread lock approach of using the synchronized keyword with HashMap .

You might also like