1) Which of the following statements about Java's garbage collection are true? a) The garbage collector can be invoked explicitly using a Runtime object. b) The finalize method is always called before an object is garbage collected. c) Any class that includes a finalize method should invoke its superclass' finalize method. d) Garbage collection behavior is very predictable. I think b is ok.but answer say I am wrong. 2)What line of code would begin execution of a thread named myThread? My answer is new myThread().start().But Answer say me wrong.I don't know. The mock exam don't give answer key.So I need some one help me.Thank
Ques 1)Both b and C are right. Ques 2) May be the answer they wanted is run() although we need not explicitly call run(). since start() only makes the thread eligible for execution. but the line of code which makes the thread execute is run(). Anybody Correct me if i am wrong.
Answer 1.(a) is also right. You can invoke the garbage collector using <code>Runtime.gc()</code> BUT that does not guarantee it will run. When you invoke the methods you're requesting that it run. Q.2 agree with Mary