Core automation track
Java for Automation
The 20% of Java that powers 100% of your framework code.
What this track covers
Collections in a framework
Collections model test data, locator maps and report rows. Choosing the wrong one costs determinism or performance.
Why it is required: Interviewers use Collections to check whether you write framework code or just scripts.
Example: Reading login rows from JSON into a List<Map<String, String>> for a DataProvider.
1public static Object[][] rows(String path) {2 List<Map<String, String>> data = JsonReader.readList(path);3 return data.stream()4 .map(row -> new Object[]{ row.get("user"), row.get("pass"), row.get("expected") })5 .toArray(Object[][]::new);6}Expected result
A DataProvider-ready Object[][] built from an external JSON file, with no hardcoded data.
Common mistakes
- Using HashMap where report ordering matters (use LinkedHashMap)
- Raw types instead of generics
- Loading the same file once per test instead of caching
Why LinkedHashMap over HashMap in a reporting utility?
Java 8 Streams in tests
Streams turn verbose data validation loops into readable declarative assertions.
Why it is required: Almost every SDET coding round includes at least one Stream question.
Example: Assert every returned order belongs to the requested customer.
1List<Order> orders = OrderApi.forCustomer(7);2 3assertTrue(orders.stream().allMatch(o -> o.customerId() == 7));4 5Map<String, Long> byStatus = orders.stream()6 .collect(Collectors.groupingBy(Order::status, Collectors.counting()));Expected result
A single readable assertion plus a status breakdown map for reporting.
Common mistakes
- Reusing a consumed stream (IllegalStateException)
- Side effects inside forEach instead of collecting
- Using parallelStream() on tiny collections
Difference between map() and flatMap()?
Related interview questions
Open bankDifference between HashMap, LinkedHashMap and TreeMap?
HashMap = no order, O(1) average; LinkedHashMap = insertion (or access) order; TreeMap = sorted by key, O(log n), backed by a red-black tree.
How do you find duplicate characters in a String using Java 8 Streams?
Stream the chars, group by identity with counting, filter entries with count > 1.
Abstract class vs interface — which do you use in your framework and why?
Abstract class for shared state + partial implementation (BasePage, BaseTest); interface for capability contracts (Reportable, DataProvider strategy).
How do you choose between ArrayList, LinkedList, HashMap and HashSet in test code?
ArrayList for ordered, index-accessed data, HashMap for key lookups such as test data by id, HashSet for uniqueness checks, LinkedList almost never in test frameworks.
How does HashMap work internally, and why must hashCode and equals agree?
HashMap stores entries in buckets chosen by hashCode; equals resolves collisions inside a bucket. If two equal objects return different hash codes they land in different buckets and lookups silently fail.
Interface vs abstract class — how does that decision show up in a test framework?
Abstract classes share state and common behaviour (BasePage, BaseTest); interfaces declare capability contracts (Reportable, DriverProvider) and allow multiple inheritance of type.
Quick reference available
Open the matching cheat sheet for last-minute revision.