Add office photos
Deloitte logo
Premium Employer

Deloitte

Verified
3.8
based on 17.9k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Java Developer
Experienced
Skills
Clear (1)

30+ Deloitte Java Developer Interview Questions and Answers

Updated 21 Jan 2025

Q1. Sort 0 and 1 Problem Statement

Given an integer array ARR of size N containing only integers 0 and 1, implement a function to sort this array. The solution should scan the array only once without using any addi...read more

Ans.

The function sorts an integer array containing only 0s and 1s in linear time complexity.

  • Use two pointers, one starting from the beginning and the other from the end of the array.

  • Swap the elements at the pointers if the element at the beginning pointer is 1 and the element at the end pointer is 0.

  • Continue moving the pointers towards each other until they meet in the middle of the array.

View 2 more answers
right arrow

Q2. Convert BST to Greater Sum Tree

Given a Binary Search Tree (BST) of integers, your task is to convert it into a greater sum tree. In the greater sum tree, each node's value should be replaced with the sum of al...read more

Ans.

The task is to convert a Binary Search Tree into a Greater Sum Tree.

  • Traverse the BST in reverse inorder (right, root, left) to visit nodes in descending order.

  • Keep track of the sum of all greater nodes encountered so far.

  • Update the value of each node by adding the sum of greater nodes and update the sum.

  • Continue this process until all nodes have been visited.

  • Return the modified BST.

Add your answer
right arrow

Q3. Write a code for Iterate hashmap using iterator

Ans.

Iterate through a hashmap using an iterator in Java

  • Create an iterator using the entrySet() method of the hashmap

  • Use a while loop to iterate through the hashmap entries

  • Access the key and value of each entry using the getKey() and getValue() methods

View 1 answer
right arrow

Q4. Do you have exp in Kubernetes?

Ans.

Yes, I have experience in Kubernetes.

  • I have worked on deploying and managing applications on Kubernetes clusters.

  • I am familiar with creating and managing Kubernetes resources such as pods, deployments, services, and ingresses.

  • I have experience in using tools like kubectl and Helm for interacting with Kubernetes clusters.

  • I have implemented CI/CD pipelines using Kubernetes for automated deployment and scaling of applications.

Add your answer
right arrow
Discover Deloitte interview dos and don'ts from real experiences

Q5. What is @PreAuthorize and @PostAuthorize

Ans.

Annotations used in Spring Security to apply authorization rules before and after a method is called.

  • Used in Spring Security to define authorization rules

  • @PreAuthorize is used to apply authorization rules before a method is called

  • @PostAuthorize is used to apply authorization rules after a method is called

  • Both annotations support SpEL expressions for defining rules

Add your answer
right arrow

Q6. How much exp in docker?

Ans.

I have 2 years of experience working with Docker in various projects.

  • 2 years of experience working with Docker in various projects

  • Proficient in creating Docker containers, managing images, and orchestrating containers using Docker Compose

  • Familiar with Docker Swarm and Kubernetes for container orchestration

  • Experience in troubleshooting Docker-related issues and optimizing container performance

Add your answer
right arrow
Are these interview questions helpful?

Q7. how authentication and authorization works in java

Ans.

Authentication verifies the identity of a user, while authorization determines what actions they are allowed to perform.

  • Authentication is the process of verifying the identity of a user, typically through credentials like username and password.

  • Authorization determines what actions a user is allowed to perform after they have been authenticated.

  • Java provides various authentication mechanisms like Basic Authentication, Digest Authentication, and OAuth.

  • Authorization in Java can ...read more

Add your answer
right arrow

Q8. What is spring profile

Ans.

Spring profile is a way to segregate parts of your application configuration and make it only available in certain environments.

  • Spring profiles allow you to define different configurations for different environments such as development, testing, and production.

  • You can use @Profile annotation to specify which beans should be loaded based on the active profile.

  • Profiles can be activated in various ways such as through application properties, environment variables, or command lin...read more

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Explain Oops Concept, keywords in java, access specifiers

Ans.

OOPs concept in Java includes keywords and access specifiers for defining classes and objects.

  • OOPs concept focuses on objects and classes for code organization

  • Keywords like 'class', 'extends', 'implements' are used for defining classes and inheritance

  • Access specifiers like 'public', 'private', 'protected' control visibility of class members

Add your answer
right arrow

Q10. java 8 features, write lambda function to add two numbers

Ans.

Lambda functions in Java 8 allow for concise and functional programming style.

  • Use the lambda operator '->' to define the lambda function.

  • Specify the parameters and the body of the lambda function.

  • Example: (int a, int b) -> a + b

Add your answer
right arrow

Q11. Find second Max salary? How internally hashmap grows its size? SOLID principles?

Ans.

To find the second highest salary, sort the salaries in descending order and skip the first one.

  • Sort the salaries in descending order

  • Skip the first salary to get the second highest salary

  • Handle edge cases like duplicates or null values

Add your answer
right arrow

Q12. What is OOP?

Ans.

OOP stands for Object-Oriented Programming, a programming paradigm based on the concept of objects.

  • OOP focuses on creating objects that contain data and methods to manipulate that data.

  • Encapsulation, inheritance, and polymorphism are key principles of OOP.

  • Examples of OOP languages include Java, C++, and Python.

Add your answer
right arrow

Q13. Coding question - find repeat elements in an array

Ans.

Find repeat elements in an array of strings

  • Iterate through the array and store each element in a HashMap with its count

  • Check if the count of any element is greater than 1, then it is a repeat element

  • Return the repeat elements found in the array

View 1 answer
right arrow

Q14. Explain the architecture for a student management system in springboot

Ans.

A student management system in SpringBoot involves multiple layers like controller, service, repository, and database.

  • Use SpringBoot for creating RESTful APIs to handle student data

  • Implement controller layer to handle incoming HTTP requests and route them to appropriate service methods

  • Service layer contains business logic for managing student data

  • Repository layer interacts with the database to perform CRUD operations on student entities

  • Use JPA for mapping Java objects to data...read more

Add your answer
right arrow

Q15. What is hashmap

Ans.

HashMap is a data structure in Java that stores key-value pairs and allows fast retrieval of values based on keys.

  • HashMap implements the Map interface in Java

  • It allows null keys and values

  • Keys in a HashMap must be unique

  • Example: HashMap map = new HashMap<>()

Add your answer
right arrow

Q16. Internal Working of hashmap

Ans.

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

  • HashMap uses the hashCode() method of keys to calculate the hash value.

  • HashMap allows one null key and multi...read more

View 1 answer
right arrow

Q17. Types of polymorphism

Ans.

Polymorphism in Java refers to the ability of a method to do different things based on the object it is acting upon.

  • Types of polymorphism in Java include method overloading and method overriding.

  • Method overloading is when multiple methods have the same name but different parameters.

  • Method overriding is when a subclass provides a specific implementation of a method that is already defined in its superclass.

Add your answer
right arrow

Q18. Compare Throw vs Throws

Ans.

Throw is used to explicitly throw an exception in a method, while Throws is used to declare the exceptions that a method may throw.

  • Throw is used within a method to throw an exception explicitly.

  • Throws is used in the method signature to declare the exceptions that the method may throw.

  • Throw is followed by an instance of Throwable class, while Throws is followed by the exception class names separated by commas.

  • Example: throw new IllegalArgumentException();

  • Example: public void m...read more

Add your answer
right arrow

Q19. Arraylist vs LinkedList/Vector

Ans.

ArrayList is resizable array implementation, LinkedList is doubly linked list implementation, Vector is synchronized version of ArrayList.

  • ArrayList is faster for accessing elements, LinkedList is faster for adding/removing elements in middle.

  • ArrayList uses less memory than LinkedList due to contiguous memory allocation.

  • Vector is thread-safe but slower than ArrayList due to synchronization overhead.

Add your answer
right arrow

Q20. How does Hashmap works internally

Ans.

HashMap is an implementation of Map interface that stores key-value pairs using a hash table.

  • HashMap uses hashing to store and retrieve elements.

  • It uses an array of linked lists to handle collisions.

  • The hash code of the key is used to determine the index of the array.

  • If multiple keys have the same hash code, they are stored in the same linked list.

  • When retrieving a value, the hash code is used to find the correct linked list and then linearly search for the key.

  • HashMap allows...read more

Add your answer
right arrow

Q21. Build a basic CRUD REST API endpoint

Ans.

Build a basic CRUD REST API endpoint

  • Create a REST API endpoint for each CRUD operation (Create, Read, Update, Delete)

  • Use HTTP methods like POST, GET, PUT, DELETE to perform CRUD operations

  • Implement data validation and error handling for each operation

  • Utilize a framework like Spring Boot or Express.js to simplify API development

Add your answer
right arrow

Q22. SQL question - third highest salary

Ans.

To find the third highest salary in a SQL table, you can use the 'SELECT TOP 1' statement with 'ORDER BY salary DESC OFFSET 2 ROWS FETCH NEXT 1 ROWS ONLY'.

  • Use the 'SELECT TOP 1' statement to retrieve only one record

  • Order the records by salary in descending order using 'ORDER BY salary DESC'

  • Skip the first two highest salaries using 'OFFSET 2 ROWS'

  • Fetch the next record after skipping the first two using 'FETCH NEXT 1 ROWS ONLY'

Add your answer
right arrow

Q23. Array vs Arraylist

Ans.

Arrays are fixed in size, while ArrayLists can dynamically resize. ArrayLists provide more flexibility and functionality.

  • Arrays have a fixed size, while ArrayLists can dynamically resize.

  • ArrayLists can easily add, remove, or modify elements, while arrays require manual shifting of elements.

  • Arrays use [] syntax for declaration and initialization, while ArrayLists use the ArrayList class from the Java Collections framework.

Add your answer
right arrow

Q24. how to create rest API

Ans.

To create a REST API, you need to define endpoints, implement CRUD operations, handle HTTP methods, and use frameworks like Spring Boot.

  • Define endpoints for different resources (e.g. /users, /products)

  • Implement CRUD operations (Create, Read, Update, Delete) for each endpoint

  • Handle HTTP methods like GET, POST, PUT, DELETE

  • Use frameworks like Spring Boot to simplify API development

Add your answer
right arrow

Q25. Thread in java

Ans.

Threads in Java allow multiple tasks to run concurrently within a single program.

  • Threads are lightweight sub-processes that share the same memory space.

  • They are used to improve performance by allowing tasks to run simultaneously.

  • Examples include creating a new thread using the Thread class or implementing the Runnable interface.

Add your answer
right arrow

Q26. What are java solid principles

Ans.

Java SOLID principles are a set of design principles that help in creating maintainable and scalable software.

  • 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 must be substitutable for their base types.

  • I - Interface Segregation Principle: Clients should not be forced to depend on interfaces they do ...read more

Add your answer
right arrow

Q27. Diff between arraylist and linkedlist

Ans.

ArrayList is implemented using a dynamic array while LinkedList is implemented using a doubly linked list.

  • ArrayList provides fast random access and slower insertion/deletion, while LinkedList provides fast insertion/deletion and slower random access.

  • ArrayList uses more memory as it needs to allocate a fixed-size array, while LinkedList uses more memory for storing references to the next and previous elements.

  • Example: ArrayList is suitable for scenarios where random access is ...read more

Add your answer
right arrow

Q28. Difference between hashmap and hashtable

Ans.

HashMap is non-synchronized and allows null values, while Hashtable is synchronized and does not allow null keys or values.

  • HashMap is non-synchronized, meaning it is not thread-safe, while Hashtable is synchronized and thread-safe.

  • HashMap allows null values and one null key, while Hashtable does not allow null keys or values.

  • HashMap is generally preferred for non-thread-safe applications, while Hashtable is used in thread-safe scenarios.

Add your answer
right arrow

Q29. Diff between set and list

Ans.

Set is a collection of unique elements with no specific order, while list is a collection of elements with a specific order and allows duplicates.

  • Set does not allow duplicate elements, while list allows duplicates.

  • Set does not maintain insertion order, while list maintains insertion order.

  • Examples: HashSet is a set implementation, ArrayList is a list implementation.

Add your answer
right arrow

Q30. coding reverse a palindrome

Ans.

Reverse a palindrome string using Java

  • Create a function to check if a string is a palindrome

  • If the string is a palindrome, reverse it using a StringBuilder

  • Return the reversed string

Add your answer
right arrow

Q31. solid design principles

Ans.

Solid design principles are a set of best practices for designing software that is maintainable, scalable, and flexible.

  • Single Responsibility Principle - each class should have only one responsibility

  • Open/Closed Principle - classes should be open for extension but closed for modification

  • Liskov Substitution Principle - objects of a superclass should be replaceable with objects of its subclasses without affecting the program's correctness

  • Interface Segregation Principle - client...read more

Add your answer
right arrow

Q32. design patterns in java

Ans.

Design patterns in Java are reusable solutions to common problems in software design.

  • Design patterns help in creating flexible, maintainable, and scalable code.

  • Examples of design patterns in Java include Singleton, Factory, Observer, and Strategy.

  • Each design pattern has its own purpose and can be applied in different scenarios.

  • Understanding design patterns is essential for Java developers to write efficient code.

Add your answer
right arrow

Q33. Working of hashset

Ans.

HashSet is a collection that does not allow duplicate elements and does not guarantee the order of elements.

  • HashSet uses a hash table for storage.

  • Elements are stored based on their hash code.

  • Adding an element to a HashSet returns false if the element is already present.

  • Example: HashSet set = new HashSet<>(); set.add("apple");

Add your answer
right arrow

Q34. Program on sorting

Ans.

Sorting program to arrange strings in alphabetical order

  • Use Arrays.sort() method to sort the array of strings

  • Implement a custom Comparator to sort in a specific order

  • Consider using Collections.sort() for sorting ArrayList of strings

Add your answer
right arrow
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Deloitte Java Developer

based on 19 interviews
2 Interview rounds
Technical Round - 1
Technical Round - 2
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Java Developer Interview Questions from Similar Companies

Capgemini Logo
3.7
 • 86 Interview Questions
Accenture Logo
3.8
 • 45 Interview Questions
Cognizant Logo
3.7
 • 21 Interview Questions
View all
Recently Viewed
LIST OF COMPANIES
Dalmia Bharat Group
Locations
INTERVIEWS
UltraTech Cement
No Interviews
INTERVIEWS
Larsen & Toubro Group
No Interviews
INTERVIEWS
Accenture
No Interviews
INTERVIEWS
UltraTech Cement
No Interviews
LIST OF COMPANIES
Electrosteel Casting
Locations
LIST OF COMPANIES
Saint Gobain Glass
Locations
LIST OF COMPANIES
JK Lakshmi Cement
Locations
REVIEWS
AU Small Finance Bank
No Reviews
INTERVIEWS
Ori-Plast
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

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