Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dans GC Mock - Problem ?

 
Michael Taupitz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Dans Mock-Exam about GC (Study Guide Chapter 8, Mock 1) is a problem about the correct answer.

Which of the following are true statements and which of the following could be a result of attempting to compile and run the program?
a. Prints: XY
b. Prints: YX
c. Prints: XXYY
d. Prints: YYXX
e. Nothing is printed.
f. There is no guarantee that the garbage collector will run.
g. Compiler Error.
h. Run Time Error.
i. None of the above.
-------------------------------------
Dan says answers a,b,e,f .
But, if answer f is correct (and i would say, thats the only correct answer) all other answers are incorrect - or ?
Michael
 
Vivek Talyan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Taupitz:
In Dans Mock-Exam about GC (Study Guide Chapter 8, Mock 1) is a problem about the correct answer.

Which of the following are true statements and which of the following could be a result of attempting to compile and run the program?
a. Prints: XY
b. Prints: YX
c. Prints: XXYY
d. Prints: YYXX
e. Nothing is printed.
f. There is no guarantee that the garbage collector will run.
g. Compiler Error.
h. Run Time Error.
i. None of the above.
-------------------------------------
Dan says answers a,b,e,f .
But, if answer f is correct (and i would say, thats the only correct answer) all other answers are incorrect - or ?
Michael

The question asks you what 'could' happen. So, if the garbage collection runs and the objects of class B are garbage collected, 'a' and 'b' might happen. Otherwise, if the gc does not run (which is what 'f' says) then nothing will be printed.
 
Michael Taupitz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Vivek, i'd overseen this could. But is it correct to say - what could happen - or not.
Mayba all can happen - it could also happen a OutOfMemoryException - or ? ;-)
Okay, but this gives me a feeling for the real exam..... ;-)
Michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic