Which one is used for the Finalize method, declared with the access specifier?
-
Public
-
Private
-
Protected
-
Package
C
Correct answer
Explanation
Protected is an access specifier.It allows subclasses to inherit the protected thing, even if those classes are outside the package of the super class they extend means a protected class can be inherited outside the package(another package). Protected access specifier is used with finalize method for garbage collection when an object is being garbage collected, the garbage collector will call a special method called finalize in the object. It is also used for cleanup code and to avoid circular references.