class Account { Long accNum, pwd}
public class Banker {
    public static void main(String r[]) {
        new Banker().go();
        // do more stuff }

    void go() {
        Account a1 = new Account();
        a1.accNum = new Long("1024");
        Account a2 = a1;
        Account a3 = a2;
        a3.pwd = a1.accNum.longValue();
        a2.pwd = 4455L;

It says in solution when line 5, "//do more stuff" is reached, four objects are eligible for GC.

Three I know is Banker(), Account() and Long("1024"). My doubt is which is the fourth one?
It says in solution that "Account object has two Long objects associated with it". So my guess is 4455L is considered an object, making it the fourth object eligible for GC? If so afterall, my second doubt is isn't it a primitive value?

Edited by rahul.ch

5 Years
Discussion Span
Last Post by rahul.ch
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.