Computer Science, asked by yeshwanthraghav, 1 year ago

difference between finalize() and finally() in java...

Answers

Answered by bmohankumar
0
Finally is a block which always executes when the try block exits. It is executed even if an unexpected exception occurs. It used in Exception Handling.

Finalize is a method which is used b4 an object is garbage collected, the runtime system calls its finalize() method. Resources release code in Finalize() method before getting garbage collected.
Answered by Oreki
1

\begin{tabular} {l|r} \textbf{finally} & \textbf{finalize}\\  \textsf{$\cdot$ Block} & \textsf{Method $\cdot$}\\ \textsf{$\cdot$ A block that executes after } & \textsf{Executed just before the $\cdot$}\\  \textsf{\hspace{.37em} the try-catch blocks, if d\symbol{101}fined} & \textsf{object is collected by the GC \hspace{.37em}}\end{tabular}

Similar questions