This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

what is the answer

 
nikunj thakur
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
class CardBoard {
Short story = 5;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
}
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
// do Stuff
} }

When // doStuff is reached, how many objects are eligible for GC?

0

1

2

Compilation fails.

It is not possible to know.

An exception is thrown at runtime


The answer is 2 objects are eligible
C1 and Short
but c3 is also null then wy c3 is not available
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by nikunj thakur:
...c3 is also null then wy c3 is not available

The answer is the same as when you posted this question a week ago.
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi!
you can go here for some help!
 
    Bookmark Topic Watch Topic
  • New Topic