Right Place For Right PersonTM 
Sponsored Ads
Buy This Website(This website is for Sale)
Home Tutorials Articles Forums Source Code Books Certifications Interviews Questions

Previous Home Next

Sun Java Certification Program

Garbage Collection & Object Lifetime

Questions 1 Which of the following statements about Java grabage collection are true statements?
(a) The following code will start the garabage collection mechanism:
Runtime.getRuntime().gc();
Thread.yield();
(b) The following code will start the garbage collection mechanism:
System.gc();
Thread.sleep(1000);
(c) The garbage collection Thread has a low priority.
(d) The method by which Java tracks unused objects is specified in the language definition.
(e) The method by which Java determines that a chunk of memory is garbage is up to the implementor of the JVM.

Questions 2 Which of the following statements about finalize methods is true?
(a) The purpose of a finalize method is to recover system resources other than memory.
(b) The purpose of a finalize method is to recover memory and other system resources.
(c) You should always write a finalize method for every class.
(d) The order in which objects are created controls the order in which their finalize methods are called.

Questions 3 After which line the object initially refered by str is eligible for garbage
collection?
Select one correct answer.
1 class Garbage
2 {
3 public static void main(String arg[])
4 {
5 String str=new String("Hello");
6 String str1=str;
7 str=new String("Hi");
8 str1=new String("Hello Again");
9 return;
10 }
11 }
(a) After line no. 6
(b) After line no. 7
(c) After line no. 8
(d) After line no. 9

Answers: 1 (c), (e)
Answer (c) is correct because the JVM ssigns a low priority to the garbage collection thread. Answer (e) is also correct because picking the best garbage collection method is left up to the individual JVM implementor. Answer (a), (b) are incorrect because of the phrase “will start” these code fragments “may” start the garbage collector, but there is no guarantee. Answer (d) is incorrect because the langauge specification does not prescribe a method.

Answers: 2 (a)
Answer (b) is incorrect because memory is recovered by garbage collection; finalizers are for other resources. Answer (c) is incorrect because objects that do not use system resources other than memory do not need finalizers. Answer (d) is incorrect because there is no guarantee about the order of object finalization.

Answers:3 (c)
At line no. 7 str refers to a new object but its previous object is still refered by str1 at that time.At line no. 8 str1 changes its reference then the object initially refered by str is eligible for garbage collection.

Previous Home Next
Sponsored Ads
Sponsored Ads
Sponsored Ads
Sponsored Ads
Sponsored Ads
Interview Questions And Answers
Struts interview questions and answers (Subjective)
500 Java Objective Questions and Answer
Core Java Objective Questions And Answers
Core Java Subjective Questions And Answers
Core Java Interview Questions And Answers
Core Java Interview Questions and Answers (Subjective)
Core Java Interview Questions and Answers( Objective)
50 Servlet interview questions
155 Java Interview Questions
EJB Interview Questions and Answers(Subjective)
R4R,JSP Interview Questions and Answer(Subjective)
R4R,Java Servlets Interview Questions and Answers(Subjective)
Core Java Subjective ,Objective and Interview Questions And Answers
275 Core java interview questions
Java Objective Questions and Answer
Java Architect Interview Questions
Applet Interview Questions and Answers
Core Java example
Servlet Objective Questions And Answers
Servlet Subjective Questions And Answers
Servlet Interview Questions And Answers
JSP Objective Questions And Answers
JSP Subjective Questions And Answers
JSP Interview Questions And Answers
JDBC Objective Questions And Answers
JDBC Subjective Questions And Answers
JDBC Interview Questions And Answers
JDBC Interview questions and answers
Networking Interview questions and answers
Servlets Interview questions and answers
EJB Objective Questions And Answers
EJB Subjective Questions And Answers
EJB Interview Questions And Answers
Hibernate Objective Questions And Answers
Hibernate Subjective Questions And Answers
Hibernate Interview Questions And Answers
Spring Objective Questions And Answers
Spring Subjective Questions And Answers
Spring Interview Questions And Answers
Struts Objective Questions And Answers
Struts Subjective Questions And Answers
Struts Interview Questions And Answers
Ant Objective Questions And Answers
Ant Subjective Questions And Answers
Ant Interview Questions And Answers
PHP Objective Questions And Answers
PHP Subjective Questions And Answers
PHP Interview Questions And Answers 1
ASP.net Objective Questions And Answers
ASP.net Subjective Questions And Answers
ASP.net Interview Questions And Answers 1
ASP.net interview questions ,ASP.net interview answers,ASP.net interview questions and answers
PHP interview questions ,PHP interview answers,PHP interview questions and answers
Testing Objective Questions And Answers
Testing Subjective Questions And Answers
Testing Interview Questions And Answers
Ajax Tutorials
Ajax Objective Questions And Answers
Ajax Subjective Questions And Answers
Ajax Interview Questions And Answers
Linux Objective Questions And Answers
Linux Subjective Questions And Answers
Unix Subjective Questions And Answers
Unix Interview Questions And Answers
HR interview questions and answers
HR Interview Questions Tips
HR Objective Questions And Answers
HR Subjective Questions And Answers
HR Interview Questions And Answers
Learn C Language with in a day
 C /C++ Questions
C Objective Questions And Answers
C Subjective Questions And Answers
C Interview Questions And Answers
C Objective Interview Questions And Answers(10)
C Subjective Interview Questions And Answers(100) 
C syntax,semantics and simple programming questions(61) 

Linux Interview Questions And Answers
Unix Objective Questions And Answers
C Aptitude Questions(179)
C++ Interview Questions And Answers    
C++ Objective Questions And Answers
C++ Subjective Questions And Answers
C++ Interview Questions And Answers
C,C++ objective Interview Questions and answers
C Interview Questions And Answers( Objective and Subjective)
C Objective Interview Questions And Answers(10)

C Subjective Interview Questions And Answers(100)

C,C++ Interview Questions

35 C++ Interview Questions And Answers(Subjective)

109 C++ Interview Questions

Java Script Interview Question and Answer(1-10).
 Java Script Interview Question and Answer(11-20).
Java Script  Interview Question and Answer(21-30).
Java Script Interview Question and Answer(31-40).
Javascript Objective Questions And Answers
Javascript Subjective Questions And Answers
Javascript Interview Questions And Answers
MFC Interview Questions And Answers(Subjective)

MFC Interview Questions And Answers(Subjective)

ATL Interview Questions And Answers(Subjective)

COM DCOM Interview Questions And Answers(Subjective)

Win32API Interview Questions And Answers(Subjective)

ActiveX Interview Questions And Answers(Subjective)

R4R, VC++ AllOther Interview Questions And Answers(Subjective)

PL/SQL Interview Questions And Answers(Subjective)

152 PL/SQL Interview Questions And Answers(Subjective)

Asp Objective Questions And Answers
Asp Subjective Questions And Answers
Asp Interview Questions And Answers 1

VB Objective Questions And Answers

Contact US:

Your Name:


Your Email:

Message:

Comments:

Give Your Comments:


Advertiser PRIVACY POLICY ||User PRIVACY POLICY || R4R Group Srvices