Automation Interview
Core Java Interview Questions for Selenium Testers
Practice core Java interview questions Selenium testers face, with model answers, runnable code, OOP, collections, exceptions, streams, and WebDriver examples.
22 min read | 3,487 words
TL;DR
For Selenium interviews, Core Java depth matters most where language choices affect test reliability: object design, equality, collections, exception boundaries, generics, streams, and concurrency. Give precise rules, show a short example, and explain the automation consequence.
Key Takeaways
- Answer Java questions with the rule first, then connect the rule to a concrete automation framework decision.
- Know value equality, immutability, collections, generics, exceptions, streams, and lifecycle well enough to debug unfamiliar code.
- Use composition for page components and services, and reserve inheritance for a genuine stable is-a relationship.
- Choose collections from ordering, uniqueness, lookup, and concurrency requirements instead of habit.
- Handle recoverable conditions at the right layer, preserve causes, and never hide Selenium failures with broad catches.
- Treat WebDriver, test data, and reports as scoped resources when suites run in parallel.
- Practice small compilable programs because interviewers evaluate reasoning, edge cases, naming, and verification.
The most useful core java interview questions selenium testers receive are not trivia checks. They test whether you can design maintainable automation, diagnose a failed collection lookup, preserve a useful exception, and keep parallel WebDriver sessions isolated.
This guide connects Java fundamentals to real Selenium framework decisions. It includes runnable Java and current Selenium examples, an answer structure for interviews, live-coding patterns, and a large question bank you can rehearse aloud.
TL;DR
| Java topic | What an interviewer listens for | Automation connection |
|---|---|---|
| Equality | Difference between identity and value | Comparing domain objects and deduplicating data |
| Immutability | Stable state and safe sharing | Configuration, locators, expected data |
| Collections | Ordering, uniqueness, lookup, complexity | Test data, window handles, results |
| Exceptions | Specific handling and preserved cause | Selenium failure diagnosis |
| Generics | Compile-time type safety | Page components, wait helpers, data providers |
| Streams | Clear transformations without hidden effects | Filtering results and building assertions |
| Concurrency | Isolation and thread ownership | Parallel WebDriver sessions |
| OOP | Cohesion, composition, small contracts | Page objects and test services |
A strong answer usually has four parts: definition, rule, small example, and framework consequence. Stop when the question is answered, then invite the interviewer to go deeper.
1. Prepare for core java interview questions selenium testers face
Map the role before memorizing answers. A UI automation position typically expects Java syntax, object-oriented design, collections, exception handling, build tools, JUnit or TestNG, and Selenium WebDriver. A senior SDET role may add concurrency, HTTP clients, database access, design patterns, and framework architecture.
Build a revision sheet with three confidence levels:
- Explain: You can state the rule accurately in under one minute.
- Code: You can implement a small example without an IDE suggestion.
- Apply: You can explain where the rule helps or harms an automation suite.
Interviewers often start with a simple question and probe. For HashMap, they may move from key/value behavior to equals and hashCode, nulls, iteration order, and thread safety. Learn concept chains rather than isolated sentences.
Use honest version language. Java 21 is a long-term-support release widely used in automation, while newer Java releases may exist in an interview environment. Avoid claiming that a feature is new unless you know its release status. Core rules for classes, records, collections, exceptions, and streams remain stable.
Create examples from your own framework. If asked about composition, describe a LoginPage using a reusable HeaderComponent. If asked about maps, describe indexing test users by role. Specific application shows understanding without exposing confidential code.
Finally, practice follow-up questions: What would change under parallel execution? What happens with null? Who owns cleanup? What is the time complexity? How would you test this method? Those probes distinguish working knowledge from memorization.
2. Explain Java types, variables, and parameter passing precisely
Java has primitive types and reference types. Primitive variables hold values such as int, boolean, and double. Reference variables hold references to objects such as String, List, or a page object. A null value applies to references, not primitives.
Java is always pass-by-value. When a primitive is passed, the method receives a copied primitive value. When an object reference is passed, the method receives a copied reference value. Both references can point to the same mutable object, so the method can mutate that object. Reassigning the parameter does not reassign the caller's variable.
import java.util.ArrayList;
import java.util.List;
public class PassingExample {
static void addFailure(List<String> failures) {
failures.add("Login button not clickable");
}
static void replaceList(List<String> failures) {
failures = new ArrayList<>();
failures.add("Only visible inside this method");
}
public static void main(String[] args) {
List<String> failures = new ArrayList<>();
addFailure(failures);
replaceList(failures);
System.out.println(failures);
}
}
The output contains only the login failure. The object was mutated by addFailure, while replaceList changed only its local copy of the reference.
Know widening and narrowing conversions. Widening from int to long is implicit and generally safe. Narrowing from long to int needs a cast and can lose information. In test automation, careless numeric conversion can corrupt timestamps, IDs, or durations.
Use wrapper classes when an object is required, such as List
3. Apply OOP principles to a Selenium framework
Encapsulation keeps state and behavior together behind a useful interface. A page object should expose actions such as loginAs(user), not every locator as a public field. This prevents tests from duplicating interaction details.
Abstraction presents what a caller needs without leaking implementation. An AuthenticationService contract could support UI and API implementations. Polymorphism lets a caller use either through the same interface when the behavior contract is genuine.
Inheritance represents a stable is-a relationship. It is frequently overused in automation. A BasePage containing dozens of unrelated clicks, waits, JavaScript helpers, screenshots, API calls, and assertions becomes a global dependency. Composition is usually clearer: a page owns a Waits helper, HeaderComponent, and domain service.
public interface Authentication {
void loginAs(User user);
}
public record User(String username, String password) {
public User {
if (username == null || username.isBlank()) {
throw new IllegalArgumentException("username is required");
}
}
}
public final class LoginPage implements Authentication {
private final LoginForm form;
public LoginPage(LoginForm form) {
this.form = form;
}
@Override
public void loginAs(User user) {
form.enterUsername(user.username());
form.enterPassword(user.password());
form.submit();
}
}
The record is an immutable value carrier with generated accessors, equals, hashCode, and toString. The compact constructor enforces a domain rule. The page depends on a small component rather than inheriting a universal base.
When explaining SOLID, avoid reciting initials only. Give a tradeoff. A dedicated DriverFactory has one reason to change, while a page object that also creates drivers, reads CSV, and sends reports violates cohesion. An interface with one implementation is not automatically valuable. Add an abstraction when it protects a real variation or boundary.
4. Master strings, equality, hashing, and immutability
String is immutable. Operations such as trim, replace, or toUpperCase return another String rather than changing the original. Immutability makes strings safe to share, pool, cache, and use as map keys.
The == operator compares primitive values or reference identity. The equals method compares logical value when the class implements it that way. For strings, use equals or Objects.equals. Never rely on string-pool behavior.
String expected = new String("PASS");
String actual = "PASS";
System.out.println(expected == actual); // false
System.out.println(expected.equals(actual)); // true
If a class overrides equals, it must override hashCode consistently. Equal objects must have equal hash codes. Hash-based collections use the hash to select a bucket and equality to identify the matching key. Mutating fields used by equality after inserting a key can make lookup fail.
Records are useful for immutable test values:
public record TestResult(String testId, String status) {}
var first = new TestResult("login-01", "PASS");
var second = new TestResult("login-01", "PASS");
System.out.println(first.equals(second)); // true
Use StringBuilder for repeated string construction in a loop. String concatenation is fine for a few values and often optimized, but building a large report fragment with repeated plus operations creates intermediate objects.
Immutability does not mean every referenced object is deeply immutable. A final List field cannot be reassigned, but its contents may still change. Use List.copyOf in a constructor and expose an unmodifiable value when stable expected data matters.
5. Choose collections and generics from requirements
List preserves encounter order and allows duplicates. Set represents uniqueness. Map associates keys with values. Queue models ordered processing. Choose the abstraction from the behavior, then choose an implementation.
| Need | Typical choice | Interview caveat |
|---|---|---|
| Ordered test steps, duplicates allowed | ArrayList | Middle insertion can shift elements |
| Unique IDs, no order promise | HashSet | Requires correct equality and hashing |
| Unique IDs, insertion order | LinkedHashSet | Extra bookkeeping |
| Sorted unique values | TreeSet | Elements need ordering |
| Fast lookup by role or key | HashMap | No iteration-order contract |
| Insertion-ordered lookup | LinkedHashMap | Not sorted |
| Concurrent key/value updates | ConcurrentHashMap | Compound actions still need design |
Generics provide compile-time type safety. List
This standalone program deduplicates results by test ID while retaining insertion order:
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class ResultIndex {
record Result(String testId, String status) {}
static Map<String, Result> indexLatest(List<Result> results) {
Map<String, Result> byId = new LinkedHashMap<>();
for (Result result : results) {
byId.put(result.testId(), result);
}
return Map.copyOf(byId);
}
public static void main(String[] args) {
var results = List.of(
new Result("login", "FAIL"),
new Result("search", "PASS"),
new Result("login", "PASS")
);
System.out.println(indexLatest(results));
}
}
Be careful when claiming performance. HashMap lookup is expected constant time under normal hashing, not an unconditional guarantee for every case. ArrayList access by index is constant time, while finding a value is linear.
Read Selenium vs Cypress architecture if an interview moves from Java collections into tool architecture and process models.
6. Handle exceptions without hiding the cause
Checked exceptions must be caught or declared. RuntimeException and its subclasses are unchecked. The distinction does not mean checked equals recoverable or unchecked equals programmer fault in every design. It is a compiler rule plus an API decision.
Catch an exception only when the current layer can recover, add useful context, translate it to a domain-specific failure, or guarantee cleanup. Catch the most specific type practical. Preserve the original exception as the cause.
public final class LoginException extends RuntimeException {
public LoginException(String message, Throwable cause) {
super(message, cause);
}
}
public void login(User user) {
try {
loginPage.loginAs(user);
} catch (org.openqa.selenium.TimeoutException timeout) {
throw new LoginException(
"Login did not complete for user " + user.username(),
timeout
);
}
}
Avoid catch (Exception ignored). It can convert a real Selenium failure into a later NullPointerException or false pass. Logging and continuing is correct only when the step is explicitly optional and the test still has a valid oracle.
A finally block runs after try or catch in normal control flow and is useful for cleanup, but try-with-resources is better for AutoCloseable resources such as files, streams, JDBC connections, and statements. WebDriver cleanup is normally placed in framework lifecycle with driver.quit().
Distinguish throw from throws. throw creates an exceptional control transfer with an exception object. throws declares possible checked exceptions in a method signature. Also explain that an assertion failure is not a condition the page object should catch and suppress.
7. Use lambdas, streams, and Optional with restraint
A lambda is an implementation of a functional interface, an interface with one abstract method. Selenium wait conditions and Java predicates are common automation examples. Method references can improve readability when the target operation is already well named.
Streams describe transformations over data. They are lazy until a terminal operation runs. Intermediate operations include filter and map. Terminal operations include toList, collect, count, anyMatch, and forEach.
import java.util.List;
public class FailureFilter {
record Result(String id, String status, long durationMs) {}
public static void main(String[] args) {
List<Result> results = List.of(
new Result("login", "PASS", 420),
new Result("checkout", "FAIL", 980),
new Result("search", "FAIL", 310)
);
List<String> slowFailures = results.stream()
.filter(result -> result.status().equals("FAIL"))
.filter(result -> result.durationMs() > 500)
.map(Result::id)
.sorted()
.toList();
System.out.println(slowFailures);
}
}
Prefer side-effect-free stream operations. Mutating shared lists inside parallelStream creates races and obscures intent. A loop is often clearer for complex branching, checked exception handling, or step-by-step diagnostics.
Optional models a result that may be absent. It is useful as a return type for a lookup. It is usually awkward as a field, method parameter, or replacement for every null. Avoid calling get without proving presence. Use orElse, orElseGet, orElseThrow based on the contract, and know that orElse evaluates its fallback eagerly.
8. Explain concurrency through WebDriver isolation
Parallel tests introduce shared-memory and lifecycle problems. WebDriver instances are not intended to be used concurrently across test threads. Each parallel test or worker should own its driver, browser session, test data, and output path.
ThreadLocal can associate a driver with the current thread, but it is not a complete framework architecture. The value must be set before use, removed during cleanup, and never passed to tasks running on unrelated executor threads.
public final class DriverStore {
private static final ThreadLocal<org.openqa.selenium.WebDriver> DRIVERS =
new ThreadLocal<>();
public static void set(org.openqa.selenium.WebDriver driver) {
if (DRIVERS.get() != null) {
throw new IllegalStateException("Driver already set for thread");
}
DRIVERS.set(driver);
}
public static org.openqa.selenium.WebDriver get() {
var driver = DRIVERS.get();
if (driver == null) {
throw new IllegalStateException("No driver for current thread");
}
return driver;
}
public static void clear() {
var driver = DRIVERS.get();
try {
if (driver != null) {
driver.quit();
}
} finally {
DRIVERS.remove();
}
}
private DriverStore() {}
}
Know basic terms: race condition, atomicity, visibility, immutable sharing, synchronized blocks, locks, executors, and concurrent collections. volatile provides visibility and ordering guarantees for a variable, but does not make a compound increment atomic.
Do not propose parallelStream for UI tests. Its common pool gives poor control over browser lifecycle, thread count, reporting context, and failure handling. Use the test framework's supported parallel configuration and explicit resource ownership. For distributed execution tradeoffs, see Selenium Grid vs Playwright sharding.
9. Write current, clean Selenium Java code
Current Selenium Java manages driver binaries through Selenium Manager in common local setups, so a basic ChromeDriver can start without hard-coded executable paths. Production frameworks may use remote drivers, browser options, or managed grids.
This JUnit-style method uses explicit wait APIs and guaranteed cleanup:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class LoginCheck {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
try {
driver.get("https://example.com");
WebDriverWait wait =
new WebDriverWait(driver, Duration.ofSeconds(10));
String heading = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.tagName("h1"))
).getText();
if (!heading.equals("Example Domain")) {
throw new AssertionError("Unexpected heading: " + heading);
}
} finally {
driver.quit();
}
}
}
The example uses a public page for one polite browser navigation, not load. A real test uses an owned environment. It avoids Thread.sleep, catches no broad exception, and quits even when an assertion fails.
Keep assertions primarily in tests or domain-level assertion objects. Page objects should model interaction and state retrieval. Avoid PageFactory as an automatic answer to every design question. Standard By locators and explicit component objects are clear and work with current WebDriver APIs.
Know the difference between findElement and findElements. findElement throws NoSuchElementException when no match exists. findElements returns an empty list. Choose based on whether absence is exceptional or part of the check.
10. Practice core java interview questions selenium testers code live
Live coding is evaluated as a conversation. Restate input, output, null policy, duplicate policy, ordering, and complexity before typing. Start with a correct simple solution, test it with examples, then optimize if required.
A common task is finding duplicate test IDs while keeping first duplicate order:
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class DuplicateIds {
static Set<String> findDuplicates(List<String> ids) {
Set<String> seen = new LinkedHashSet<>();
Set<String> duplicates = new LinkedHashSet<>();
for (String id : ids) {
if (!seen.add(id)) {
duplicates.add(id);
}
}
return duplicates;
}
public static void main(String[] args) {
var ids = List.of("login", "search", "login", "cart", "search");
System.out.println(findDuplicates(ids));
}
}
Explain why two sets are used. seen detects repetition in expected constant time, while duplicates preserves uniqueness and insertion order. Time is expected O(n), space is O(n). State whether null is allowed, since HashSet permits one null but business input may reject it.
Other high-value exercises include reversing words without reversing their letters, counting characters, grouping results by status, comparing two lists with and without order, parsing test data, and implementing a retry predicate without sleeping.
After coding, walk through empty input, one item, duplicates, case sensitivity, and null. Interviewers notice candidates who verify their own work. If the problem is ambiguous, state an assumption and continue rather than freezing.
Interview Questions and Answers
Q: Is Java pass-by-reference or pass-by-value?
Java is always pass-by-value. For an object argument, the copied value is a reference to the same object, so the method can mutate that object. Reassigning the parameter changes only the method's local copy.
Q: What is the difference between == and equals?
For primitives, == compares values. For object references, it compares identity. equals can compare logical value when implemented, so strings and domain records should normally be compared with equals or Objects.equals.
Q: Why must hashCode be overridden with equals?
Hash-based collections use hashCode to find a bucket and equals to find the matching object. Equal objects must return equal hash codes. Breaking the contract can make a logically equal key impossible to retrieve.
Q: Why is String immutable?
A String value cannot change after construction. This supports safe pooling, hashing, caching, and sharing. Operations return new strings, so callers should store the returned value when a transformation is needed.
Q: ArrayList or LinkedList for automation data?
ArrayList is usually the default because indexed access is fast and append performance is good. LinkedList can add at known ends efficiently but has poor cache locality and linear indexed access. Choose from actual access patterns, not the interface name.
Q: HashMap or ConcurrentHashMap?
HashMap is not safe for unsynchronized concurrent mutation. ConcurrentHashMap supports concurrent access with stronger guarantees, but a multi-step read-then-write business operation may still need atomic methods such as compute. Driver isolation is better than storing all drivers in a shared map.
Q: What is method overloading versus overriding?
Overloading defines methods with the same name and different parameter lists, resolved at compile time. Overriding supplies subclass behavior for an inherited method with a compatible signature, dispatched at runtime. Return type alone cannot overload a method.
Q: Interface or abstract class?
Use an interface for a behavior contract that different types can implement. Use an abstract class when closely related types genuinely share state or protected implementation. Automation frameworks often benefit from small interfaces plus composition instead of deep base-class inheritance.
Q: Checked or unchecked exception?
Checked exceptions are enforced by the compiler through catch or declaration. Unchecked exceptions extend RuntimeException. The API should choose based on caller contract, not a claim that every checked exception is recoverable.
Q: final, finally, and finalize?
final restricts reassignment, overriding, or inheritance depending on context. finally is a cleanup block associated with try. finalize was an unreliable object cleanup mechanism and should not be used for WebDriver or other resources.
Q: What is a functional interface?
It has one abstract method and can be implemented with a lambda. Predicate, Function, Consumer, and Supplier are common examples. Default and static methods do not violate the single-abstract-method rule.
Q: What is the difference between map and flatMap in streams?
map converts each input into one output value. flatMap converts each input into a stream and flattens nested streams into one stream. It is useful when one test suite contains lists of cases and one combined stream is required.
Q: Is ThreadLocal enough for parallel Selenium?
No. It associates data with a thread, but the framework still needs lifecycle, cleanup, failure handling, and test-data isolation. Thread reuse also means remove is mandatory to prevent one test from inheriting stale state.
Q: How would you make a class immutable?
Make the class final or control subclassing, keep fields private and final, validate and copy mutable inputs, provide no mutators, and return defensive copies or immutable views. A record helps with shallow immutable state but mutable components still need copying.
Common Mistakes
- Reciting definitions without automation context: Add one framework consequence after the rule.
- Saying Java passes objects by reference: It passes a copied reference value.
- Using == for String content: Use equals or Objects.equals.
- Overriding equals without hashCode: Hash collections can behave incorrectly.
- Choosing HashMap while promising order: Use an ordered implementation when order is a requirement.
- Catching Exception around every Selenium step: Preserve specific failures and useful causes.
- Using Thread.sleep as synchronization: Wait for a condition with WebDriverWait.
- Sharing one WebDriver across parallel threads: Give each test worker an owned session.
- Calling parallelStream for UI tests: Use test-framework concurrency with controlled resources.
- Building a giant BasePage: Prefer focused components and services.
- Using streams for complex side effects: A clear loop is often more maintainable.
- Ignoring null and duplicate policy in coding: State assumptions and test edge cases.
- Claiming final makes an object deeply immutable: Mutable referenced content can still change.
- Forgetting cleanup after an assertion: Put driver.quit in lifecycle or finally.
Conclusion
The core java interview questions selenium testers face become manageable when you connect language rules to reliability. Equality affects test data, collection choice affects ordering and lookup, exception design affects diagnosis, and concurrency affects browser isolation.
Practice the runnable examples without copying them, explain edge cases aloud, and relate every answer to one real framework decision. That combination demonstrates both Java knowledge and the judgment expected from an automation engineer.
Interview Questions and Answers
Is Java pass-by-value or pass-by-reference?
Java is always pass-by-value. When an object is passed, the copied value is its reference, so both caller and method can reach the same mutable object. Reassigning the parameter does not reassign the caller variable.
What is the difference between == and equals in Java?
For object references, == tests whether both references identify the same object. equals tests logical value when the class implements that contract. Selenium test data and strings normally need value equality.
What is the equals and hashCode contract?
Equal objects must have equal hash codes, and equality should be reflexive, symmetric, transitive, and consistent while relevant state is unchanged. Hash collections depend on both methods. Keys should not mutate in equality-significant fields.
Why is String immutable?
A String value cannot be modified after construction, which supports safe pooling, hashing, caching, and sharing. Methods return new values. Immutability makes strings dependable map keys and test expectations.
What is the difference between overloading and overriding?
Overloading uses the same method name with different parameter lists and is resolved at compile time. Overriding replaces inherited behavior with a compatible signature and is dispatched at runtime. Return type alone is not enough for overloading.
When would you use an interface instead of an abstract class?
I use an interface for a small behavior contract across potentially unrelated implementations. An abstract class fits related types that share state or protected implementation. In automation, composition plus small interfaces often avoids brittle inheritance.
How do you choose between List, Set, and Map?
Use List for ordered elements with possible duplicates, Set for uniqueness, and Map for key-based lookup. Then select an implementation based on order, sorting, concurrency, and performance requirements.
What is the difference between checked and unchecked exceptions?
Checked exceptions must be caught or declared. Unchecked exceptions extend RuntimeException and have no compiler enforcement. The choice should reflect the API contract and what callers can reasonably do.
How should Selenium exceptions be handled?
Catch a specific exception only when the layer can recover or add useful domain context. Preserve the original cause. Never catch and ignore broad exceptions because that hides the first useful failure.
What is a functional interface?
It has one abstract method and can be represented by a lambda or method reference. Predicate, Function, Consumer, and Supplier are common examples. Default and static methods are allowed.
What is stream laziness?
Intermediate stream operations build a pipeline and do not process elements until a terminal operation is called. This enables optimization and short-circuiting. It also means a stream pipeline without a terminal operation does no useful work.
How do you make a Java class immutable?
Prevent uncontrolled subclass mutation, use private final fields, validate and defensively copy mutable inputs, provide no setters, and return immutable values or copies. Records help but do not make mutable components deeply immutable.
What does volatile guarantee?
It provides visibility and ordering guarantees for reads and writes of that variable. It does not make compound operations such as count++ atomic. Use atomic classes, synchronization, or a different ownership model for compound state.
How should WebDriver be managed in parallel tests?
Each parallel test unit should own one driver and its test data, output, and cleanup. ThreadLocal can help bind a driver to a thread, but lifecycle must set, quit, and remove it reliably. A shared driver is unsafe.
What is the difference between findElement and findElements?
findElement returns the first match and throws NoSuchElementException when none exists. findElements returns a list and returns an empty list for no matches. Choose according to whether absence is exceptional.
Why prefer composition in page-object design?
Composition lets pages use focused components and services without inheriting unrelated behavior. It makes dependencies visible and changes local. Deep BasePage inheritance often creates coupling and unclear ownership.
Frequently Asked Questions
How much Core Java is needed for a Selenium interview?
Know syntax, OOP, strings, equality, collections, generics, exceptions, streams, and basic concurrency. You should be able to code small problems and explain how each topic affects framework reliability.
Are Java collections important for Selenium testers?
Yes. Selenium APIs return collections, and frameworks use lists, sets, and maps for data, handles, results, and configuration. Interviewers expect you to choose implementations from ordering, uniqueness, lookup, and concurrency needs.
Should a Selenium tester learn Java streams?
Yes, especially filter, map, sorted, grouping, matching, and toList. Also know when a loop is clearer and why side effects in parallel streams can be unsafe.
What Java coding questions are common for automation testers?
Common tasks include duplicate detection, character counts, list comparison, result grouping, string transformation, and parsing test data. State edge cases and complexity before optimizing.
Is ThreadLocal mandatory for parallel Selenium?
No. It is one storage pattern for thread-associated drivers, not a requirement. The essential design is one driver owner per parallel unit with deterministic creation, cleanup, and data isolation.
Which Java version should I use for interview practice?
Practice on the version used by the target company when known. Java 21 is a practical long-term-support baseline, while core language and collection questions remain applicable across modern versions.
How should I answer an OOP question in a Selenium interview?
Define the principle, give a small Java example, and show a framework tradeoff. Composition of page components versus a large inherited BasePage is a strong concrete discussion.
Related Guides
- Java Coding Interview Questions for Testers (2026)
- Java Interview Questions for Selenium Automation Testers
- Java Interview Questions for QA Automation 2 Years Experience
- Java Interview Questions for QA Automation 3 Years Experience
- Java Interview Questions for QA Automation 5 Years Experience
- Java Interview Questions for QA Automation 7 Years Experience