• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Danchisholms: GC question, answer mismatch

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Which of the following could be a result of attempting to compile and run the program?
a. BaBb, B1, B2, B2
b. B1B2, null, null, Bb
c. , Ba, Bb, Bb
d. BaBbB1B2, null, null, null
e. Ba, B1, B2, Bb
f. Compile-time error
g. Run-time error
h. None of the above


Hey folk, I was reading this question rolling eyes, and after getting what
output should come, I matched it with given answers and didn't find so chose
"h" as correct.
But the answer given is "e". Very surprise for me, I took help of my
lovely compiler, I was correct; given answer is wrong.


You check it out!



Regards,
cmbhatt
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would go for e as a possible answer.

The moment we call m1 the second time, bc gets a new reference and Ba can be garbage collected (dunno if it will though)

so Ba, B1, B2, Bb is a possible answer.
However, if gc doesn't run
,B1,B2,Bb would be the output.
 
You didn't tell me he was so big. Unlike this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic