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?

pwd is defined as a Long, and a long will be auto boxed when assigned to a Long...

Got it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.