Forums Register Login

Dans GC Mock - Problem ?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
We can walk to school together. And we can both read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 727 times.
Similar Threads
finalize() not only for GC eligible Objects?
Help!!, problem with Dan question
regarding overloading-Dan Chisholm's Mock Exam question
Dan's question: ambiguous?
Oerator precedence
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:56:06.