Task:
Implement a cache that stores key-value pairs with a time-to-live (TTL). After TTL milliseconds, the entry expires and should not be returned.
import java.text.DecimalFormat;
public class Readability public static double computeScore(String text) if (text == null
Edge cases handled:
Prompt: Refactor the AlertService and MapAlertDAO classes to remove the hardcoded dependency. Use dependency injection.
This is TestDome's favorite object-oriented design question. It checks whether you understand tight coupling vs. loose coupling.
Implement a method that, given two arrays of names (strings), returns a sorted array of unique names from both arrays. testdome java questions and answers
Alex’s thoughts:
His final code:
import java.util.*;
public class MergeNames public static String[] uniqueNames(String[] arr1, String[] arr2) Set<String> set = new TreeSet<>(); for (String name : arr1) set.add(name); for (String name : arr2) set.add(name); return set.toArray(new String[0]);Task: Implement a cache that stores key-value pairs
✅ TestDome passes: O(n log n) time, handles duplicates, sorted result.
Sample Question:
Given a list of Product objects (name, price, category), return the sum of prices for all products in category "Electronics", but only if the price > 100. Use Java streams. Edge cases handled: