Win a copy of Spring Boot in Practice this week in the Spring forum!

Roopa Gowda

+ Follow
since Feb 24, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roopa Gowda

thankyou Adrian and Corey for a very good explanation.
this is a question on threads

the answer is : ABC
how can u be sure that the thread t1 starts executing before the main thread completes its execution.
t1 is created by the main thread and hence its priority is same as that of the main
i think the answer can be either ABC or XYZ ??
can someone help me
Thanks a ton.
so i1,i2,i3,i4 are local to the method and the objects r left with no references outside the method,hence eligible for gc
hope i am correct this time.

the output of i1 was same .
does it mean that i1 is still refering to the object originally created?
Hello everyone,
I am new to the forum and this is my first post.
I would really appreciate if someone can help me .
Question 4
class I {
private I other;
public void other(I i) {other = i;}
class J {
private void m1() {
I i1 = new I(), i2 = new I();
I i3 = new I(), i4 = new I();
i1.other(i3); i2.other(i1);
i3.other(i2); i4.other(i4);
public static void main (String[] args) {
new J().m1();
Which object is not eligible for garbage collection after method m1
returns? Ans: g. None of the above

i did understand that
I i1 = new I(), i2 = new I();
I i3 = new I(), i4 = new I();
creates 4 objects on the heap of type I, refered by i1,i2,i3,i4.
i1.other(i3); i2.other(i1);
i3.other(i2); i4.other(i4);
now i don't get this part.
i1.other referes to the same object as i3 does
i2.other referes to the same object as i1 does
i3.other referes to the same object as i2 does
i4.other referes to itself
but does it mean i1,i2,i3,and i4 do not refere to any object now?
these references still refer to the original objects right? [/LIST][LIST]