← LinkedIn Interview Insights

LinkedIn·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

LinkedIn technical phone screen for a software engineer role, pretty much a Java fundamentals deep dive. One question but they really wanted you to go all the way down the rabbit hole on it.

Questions Asked (1)

Q1

What are the differences between final, finally, and finalize in Java? Cover how each behaves, edge cases, and what the best practices are.

Technical Trade-offsAPI & Integrations
Author's notes

I knew the basics going in but the edge cases tripped me up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly distinguishing the three concepts: final is a keyword for immutability, finally is a block for cleanup, and finalize is a method for garbage collection. Then, for each, explain its purpose, behavior, edge cases, and best practices, emphasizing that finalize is deprecated and should be avoided. Conclude with a summary table or comparison to reinforce the differences.

Pro tip: Mention that finalize is deprecated since Java 9 and explain why (unpredictable, performance overhead), showing you keep up with modern Java practices. Also, highlight that finally always executes except in cases of JVM crash or System.exit(), demonstrating attention to edge cases.

1. Define final

Explain that final is a keyword used to declare constants, prevent inheritance, and prevent method overriding. Mention its behavior with variables, methods, and classes, and note that final variables must be initialized.

2. Define finally

Describe finally as a block used in exception handling to ensure code execution regardless of whether an exception is thrown. Discuss its typical use for cleanup (e.g., closing resources) and edge cases like System.exit().

3. Define finalize

Explain finalize as a method called by the garbage collector before reclaiming an object's memory. Note that it's deprecated, unpredictable, and should not be relied upon for resource cleanup.

4. Compare and contrast

Summarize the differences in a structured way: final is about immutability and design, finally is about control flow and cleanup, finalize is about object lifecycle and is obsolete.

5. Discuss best practices

Recommend using final for constants and design, finally for resource management (or try-with-resources), and avoiding finalize in favor of explicit cleanup methods like close().

Key Points to Mention

  • final can be applied to variables, methods, and classes; final variables are constants, final methods cannot be overridden, final classes cannot be subclassed.
  • finally block executes even if an exception occurs, but not if JVM exits via System.exit() or crashes.
  • finalize is called by the garbage collector, but its execution is not guaranteed; it's deprecated since Java 9.
  • try-with-resources (Java 7+) is preferred over finally for closing resources.
  • finalize can cause performance issues and unpredictable behavior; use explicit cleanup methods instead.
  • Edge case: finally block can override exceptions or return values if not used carefully.

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