1. Difference between == and equals()?
Answer 1: == compares primitives by value and objects by reference; equals() compares object
content when overridden.
Answer 2: I use == for primitive comparison or identity checks, and equals() for logical equality like
String values.
2. Explain OOPS concepts
Answer 1: Encapsulation, Inheritance, Polymorphism, Abstraction. Example: Car system hides
engine details, inherits features, supports different drive behaviors.
Answer 2: OOPS models real-world entities: hide data, reuse code, expose only essentials, and
allow one interface with many implementations.
3. Method overloading vs overriding
Answer 1: Overloading: same method name, different parameters. Overriding: subclass provides
new implementation.
Answer 2: Overloading is compile-time polymorphism; overriding is runtime polymorphism.
4. Access modifiers
Answer 1: public, protected, default, private control visibility.
Answer 2: I choose the least permissive access needed to improve encapsulation.
5. Abstract class vs interface
Answer 1: Abstract class can have state and implemented methods; interface defines contract.
Answer 2: Use abstract class for shared behavior, interface for capabilities.
6. Encapsulation
Answer 1: Wrapping data and methods together with private fields and getters/setters.
Answer 2: It protects data and controls access.
7. ArrayList vs LinkedList
Answer 1: ArrayList faster for random access; LinkedList better for frequent insert/delete.
Answer 2: Choose based on access vs modification pattern.
8. HashMap vs Hashtable
Answer 1: HashMap isn't synchronized and allows one null key; Hashtable is synchronized.
Answer 2: HashMap is preferred unless thread-safe legacy behavior is required.
9. HashMap internal
Answer 1: Uses hash, bucket array, linked list/tree for collisions.
Answer 2: Key hash decides bucket; equals() confirms exact key.
10. Set vs List
Answer 1: Set stores unique elements; List allows duplicates and order.
Answer 2: Use Set for uniqueness, List for ordered collections.
11. HashSet vs TreeSet
Answer 1: HashSet unordered, faster; TreeSet sorted.
Answer 2: TreeSet costs more but keeps natural/custom order.
12. Constructor
Answer 1: Initializes objects. Default and parameterized.
Answer 2: Called automatically during object creation.
13. super
Answer 1: Calls parent constructor/method and accesses parent members.
Answer 2: Useful when extending parent behavior.
14. final/finally/finalize
Answer 1: final: constant/no override; finally: always executes; finalize: old GC hook.
Answer 2: Only finally is exception-handling related.
15. Exception handling
Answer 1: try-catch-finally, throw/throws. Checked and unchecked.
Answer 2: Prevents abnormal termination and enables graceful recovery.
16. Checked vs unchecked
Answer 1: Checked verified at compile time; unchecked at runtime.
Answer 2: Checked must be handled; unchecked usually indicate programming errors.
17. Multithreading
Answer 1: Running multiple threads concurrently.
Answer 2: Improves responsiveness and CPU utilization.
18. Synchronization
Answer 1: Controls shared resource access.
Answer 2: Prevents race conditions.
19. String/StringBuilder/StringBuffer
Answer 1: String immutable; Builder mutable not thread-safe; Buffer mutable thread-safe.
Answer 2: Builder is fastest for single-threaded concatenation.
20. JVM/JRE/JDK
Answer 1: JVM runs bytecode; JRE=JVM+libraries; JDK=JRE+tools.
Answer 2: JDK is for development.
21. Selenium components
Answer 1: IDE, WebDriver, Grid.
Answer 2: WebDriver is the primary automation API.
22. RC vs WebDriver
Answer 1: RC used JS injection; WebDriver controls browser natively.
Answer 2: WebDriver is faster and modern.
23. WebDriver work
Answer 1: Uses browser drivers to send automation commands.
Answer 2: Client->Driver->Browser.
24. Locators
Answer 1: id,name,class,xpath,css,linkText,partialLinkText,tagName.
Answer 2: Prefer stable unique locators.
25. Fastest locator
Answer 1: ID.
Answer 2: Direct unique lookup.
26. findElement vs findElements
Answer 1: Single element vs list.
Answer 2: findElements returns empty list if none.
27. Dynamic elements
Answer 1: Use relative XPath/CSS, waits.
Answer 2: Avoid brittle absolute locators.
28. Hidden elements
Answer 1: Use JavaScript or trigger visibility.
Answer 2: Interact only after visible when possible.
29. Frames
Answer 1: switchTo().frame() then defaultContent().
Answer 2: Must switch context.
30. Multiple windows
Answer 1: Use window handles.
Answer 2: Switch by handle/title.
31. Alerts
Answer 1: accept,dismiss,sendKeys,getText.
Answer 2: Switch to alert first.
32. Implicit vs Explicit wait
Answer 1: Implicit global; Explicit condition-specific.
Answer 2: Prefer explicit waits.
33. FluentWait
Answer 1: Explicit wait with polling and ignored exceptions.
Answer 2: Useful for dynamic apps.
34. Dropdowns
Answer 1: Select class for standard select.
Answer 2: Use visible text/value/index.
35. Auto-suggestion
Answer 1: Type then wait and choose option.
Answer 2: Use dynamic locators.
36. Mouse hover
Answer 1: [Link]().
Answer 2: Actions class handles complex interactions.
37. Upload files
Answer 1: sendKeys(filePath).
Answer 2: Avoid OS dialogs.
38. Screenshots
Answer 1: TakesScreenshot interface.
Answer 2: Capture on failures.
39. Navigation
Answer 1: back,forward,refresh,to.
Answer 2: Browser navigation APIs.
40. Stale element
Answer 1: Re-locate element or use waits.
Answer 2: Occurs after DOM refresh.