← PayPal Interview Insights

PayPal·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

PayPal technical phone screen for a software engineer role. The whole session basically revolved around one Java fundamentals question that sounds deceptively simple but has a lot of surface area if you're not careful.

Questions Asked (1)

Q1

What are the differences between Java's final keyword, the finally block, and the finalize() method? Walk through the purpose, typical use cases, lifecycle, and any pitfalls or deprecations for each, with examples.

Technical Trade-offsSystem Design
Author's notes

Three things that sound similar and are completely unrelated, which is exactly the point.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by addressing each concept separately: final keyword, finally block, and finalize() method. For each, explain its purpose, typical use cases, lifecycle, and pitfalls/deprecations, with concise examples. Conclude by contrasting them to highlight their distinct roles in Java.

Pro tip: Mention that finalize() is deprecated since Java 9 and removed in Java 18, and suggest modern alternatives like try-with-resources and Cleaner. This shows you're up-to-date with Java evolution, which is crucial for a company like PayPal that values robust, maintainable code.

1. Define final keyword

Explain that final is a modifier applicable to variables, methods, and classes. Provide examples: final variable (constant), final method (cannot be overridden), final class (cannot be subclassed).

2. Explain finally block

Describe finally as part of exception handling that always executes after try-catch, regardless of exceptions. Mention its use for cleanup (e.g., closing resources) and note that it executes even if try block returns.

3. Describe finalize() method

Explain that finalize() was called by the garbage collector before object destruction, but it's deprecated and unreliable. Mention its lifecycle (called at most once) and pitfalls like performance issues and non-determinism.

4. Compare and contrast

Summarize key differences: final is a keyword for immutability/restriction, finally is a block for guaranteed execution, finalize() is a method for cleanup. Highlight that they serve unrelated purposes despite similar names.

5. Discuss modern alternatives

For finalize(), mention deprecation (Java 9) and removal (Java 18), and recommend try-with-resources or java.lang.ref.Cleaner for resource management. This shows awareness of best practices.

Key Points to Mention

  • final keyword: used for constants, preventing inheritance/overriding; ensures immutability and thread-safety.
  • finally block: guarantees execution for cleanup; runs even if exception thrown or return statement in try/catch.
  • finalize() method: deprecated since Java 9, removed in Java 18; called by GC but not guaranteed; can cause performance and security issues.
  • Lifecycle: final is compile-time, finally is runtime during exception handling, finalize() is during garbage collection.
  • Pitfalls: final can cause rigidity if overused; finally can mask exceptions if it throws; finalize() can resurrect objects and delay GC.
  • Examples: final int MAX = 100; try { ... } finally { ... }; protected void finalize() { ... } (deprecated).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.