• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exam

 
Hans Li
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mary Anitha
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

------------------
Jane
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic