Hughes Systique Corporation
20+ Kalimati Global Shared Services Interview Questions and Answers
Q1. 1. What are the advantages of Microservices?
Microservices offer advantages such as scalability, flexibility, and easier maintenance.
Scalability: Microservices allow for individual components to be scaled independently, making it easier to handle high traffic.
Flexibility: Microservices can be developed and deployed independently, allowing for faster development and deployment cycles.
Easier maintenance: Microservices are smaller and more focused, making it easier to identify and fix issues.
Example: Netflix uses microserv...read more
Q2. 5. Write a program to get the middle of the linked list in a single iteration? Ans - Two pointers , slow fast
Program to get the middle of a linked list in a single iteration using two pointers.
Use two pointers, slow and fast, to traverse the linked list
Move slow pointer one step at a time and fast pointer two steps at a time
When fast pointer reaches the end, slow pointer will be at the middle node
Q3. 8. Singleton in java . And how singleton can be broken
Singleton is a design pattern that restricts the instantiation of a class to one object.
Singleton pattern is used when we need to ensure that only one instance of a class is created and used throughout the application.
To implement Singleton, we make the constructor private and provide a static method to get the instance of the class.
Singleton can be broken by using reflection, serialization, and cloning.
Reflection can be used to access the private constructor and create a new...read more
Q4. 12. How to switch from one branch to other in git?
To switch from one branch to another in git, use the 'git checkout' command.
Use 'git checkout' followed by the name of the branch you want to switch to.
Make sure to commit or stash any changes before switching branches.
Example: 'git checkout new-branch'
Q5. 11. Why do we need maven clean and install?
Maven clean removes target directory and install compiles and packages the project
Maven clean removes the target directory and all the compiled classes and resources
Maven install compiles and packages the project and installs the resulting artifact into the local repository
Maven clean and install together ensure that the project is built from scratch and all dependencies are resolved
Useful when there are changes in the project dependencies or configuration
Q6. 1. How do you secure your APIs?
APIs can be secured using various methods such as authentication, encryption, rate limiting, and input validation.
Implement authentication using OAuth or JWT
Use HTTPS encryption to protect data in transit
Implement rate limiting to prevent DDoS attacks
Validate input data to prevent injection attacks
Regularly update and patch software to prevent vulnerabilities
Q7. 2. What is deadlock? How to resolve it?
Deadlock is a situation where two or more threads are blocked and waiting for each other to release resources.
Deadlock occurs when two or more threads are waiting for each other to release resources.
It can be resolved by using techniques like resource allocation graph, timeout, and prevention.
Prevention can be done by avoiding circular wait, hold and wait, and no preemption.
Example: Thread A holds resource X and waits for resource Y, while Thread B holds resource Y and waits ...read more
Q8. 4. What is future object in java?
A Future object represents the result of an asynchronous computation in Java.
Future objects are used to retrieve the result of an asynchronous computation when it becomes available.
They provide a way to check if the computation is complete, cancel the computation, and retrieve the result.
They are commonly used in multithreaded programming and in Java's Executor framework.
Example: Future
future = executor.submit(new Callable () { public Integer call() { return 42; }}); Example: ...read more
Q9. 3. How hashmap internally works?
HashMap is a data structure that stores key-value pairs and uses hashing to retrieve values quickly.
HashMap uses hashing to store and retrieve values quickly
It uses an array of buckets to store key-value pairs
The hash code of the key is used to determine the bucket where the key-value pair is stored
If two keys have the same hash code, they are stored in the same bucket as a linked list
When retrieving a value, the hash code of the key is used to find the bucket and then the li...read more
Q10. 3. What is spring filter ?
Spring filter is an interface used to intercept HTTP requests and responses.
Spring filter is used to perform tasks such as logging, security, and caching.
It can be used to modify the request or response before it reaches the controller.
Examples of Spring filters include CharacterEncodingFilter, CorsFilter, and CsrfFilter.
Q11. 9. What is @SpringBootApplication?
A convenience annotation that combines @Configuration, @EnableAutoConfiguration, and @ComponentScan.
Used to bootstrap a Spring Boot application.
Automatically configures the Spring application based on the dependencies added to the classpath.
Scans the package and its sub-packages for components and services.
Example: @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); } }
Q12. 2. What are the disadvantages?
Disadvantages of what? Please specify.
Q13. 6. Save vs Persist in hibernate ?
Save() method inserts a new record into the database, while persist() method can also be used to update an existing record.
save() method is used to insert a new record into the database
persist() method can also be used to insert a new record, but it can also be used to update an existing record
save() method returns the generated ID immediately, while persist() method does not
save() method can be called outside of a transaction, while persist() method must be called within a t...read more
Q14. 5. Lifecycle of object in hibernate ?
Hibernate manages object lifecycle through three states: transient, persistent, and detached.
When an object is created, it is in the transient state.
When the object is saved using session.save() method, it becomes persistent.
When the session is closed or the object is explicitly detached using session.evict() method, it becomes detached.
Detached objects can be re-attached to a new session using session.update() or session.merge() methods.
Objects can also be deleted using sess...read more
Q15. 7. Merge intervals problem in java
Merge overlapping intervals in Java
Sort the intervals based on their start time
Iterate through the intervals and merge overlapping ones
Use a stack to keep track of merged intervals
Q16. 6. Stack peek vs Stack pop?
Stack peek returns the top element without removing it, while stack pop removes and returns the top element.
Stack peek is used to check the top element of the stack without removing it.
Stack pop is used to remove and return the top element of the stack.
Both methods operate on the top element of the stack.
Q17. 7. RequestMapping vs Postmapping?
RequestMapping is used for all HTTP methods while PostMapping is specifically for POST requests.
RequestMapping is a general-purpose annotation for mapping HTTP requests to handler methods.
PostMapping is a specialized version of RequestMapping that only maps POST requests.
RequestMapping can be used for GET, POST, PUT, DELETE, and other HTTP methods.
PostMapping is useful when you want to handle only POST requests and ignore other HTTP methods.
Example: @RequestMapping(value = "/...read more
Q18. 10. RestController vs Controller?
RestController is used for RESTful web services while Controller is used for traditional web applications.
RestController returns data in JSON or XML format while Controller returns data in HTML format.
RestController uses @RestController annotation while Controller uses @Controller annotation.
RestController is used for building RESTful web services while Controller is used for building traditional web applications.
RestController is a specialized version of Controller in Spring...read more
Q19. 4.Linked list Vs Arraylist
Linked list is dynamic and efficient for insertion/deletion, while ArrayList is faster for random access.
Linked list uses pointers to connect nodes, while ArrayList uses an underlying array.
Linked list is better for frequent insertion/deletion, while ArrayList is better for frequent random access.
Linked list has O(1) time complexity for insertion/deletion, while ArrayList has O(n) time complexity.
Example: Linked list is used in implementing stacks, queues, and hash tables, wh...read more
Q20. 8. Scopes of bean ?
Scopes of bean refer to the visibility and lifecycle of a bean in a Spring application.
There are four scopes of bean in Spring: singleton, prototype, request, and session.
Singleton scope creates only one instance of a bean and is the default scope.
Prototype scope creates a new instance of a bean every time it is requested.
Request scope creates a new instance of a bean for each HTTP request.
Session scope creates a new instance of a bean for each HTTP session.
Scopes can be defi...read more
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month