Question library
Questions from real interviews. Drill any of them by voice in a couple of minutes, with an interviewer, a score and feedback.
You orchestrate several calls to external services using CompletableFuture. What pitfalls have you run into, and how do you work around them?SeniorThere are price providers, and each one has a price method that takes a SKU and asynchronously returns a CompletableFuture with a price. Write a method bestPrice that takes a SKU and a list of providers, queries all of them in parallel, and returns a CompletableFuture with the lowest price: providers that fail or don't respond within two seconds are skipped, and if nobody returned a price, the result completes with an error.Senior