我在一次采访中得到了以下短语:
The invocation of an Object's finalize() method is the last thing that happens before an object is garbaged collected.
我必须通过以下方式回答:
- 是的
- 错误
我选择了True
,但这是错误的。
你能解释一下为什么吗?
最佳答案
顺序不同:
- 首先对象被收集。
- 那么对象最终确定。
见 http://java.dzone.com/articles/ocajp-7-object-lifecycle-java
Object lifecycle:
- Created
- In use (strongly reachable)
- Invisible
- Unreachable
- Collected
- Finalized
- Deallocated
关于Java面试题: finalize() method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3306883/