Query on GC
Moderator: admin
-
- Posts: 4
- Joined: Mon Jan 27, 2020 11:41 am
- Contact:
Query on GC
Hi,
I need help to understand below question and also the correct answer.
Class Student{
String name;
int age;
}
and other class :
public class test{
psvm(String [] args){
Student s1 = new Student();
Student s2 = new Student();
Student s3 = new Student();
s1=s3;
s3=s2;
s2=s1; // line 1
}
}
How many object are eligible for GC after line 1
I need help to understand below question and also the correct answer.
Class Student{
String name;
int age;
}
and other class :
public class test{
psvm(String [] args){
Student s1 = new Student();
Student s2 = new Student();
Student s3 = new Student();
s1=s3;
s3=s2;
s2=s1; // line 1
}
}
How many object are eligible for GC after line 1
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Query on GC
You need to tell what do you think is the answer and why so that we can explain any issue with your reasoning.
Also, you need to quote the source from where you got this question.
Also, you need to quote the source from where you got this question.
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Query on GC
You need to draw a diagram with references and objects. Then change the references after each statement.
Which book are you following?
Which book are you following?
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Mon Jan 27, 2020 11:41 am
- Contact:
Re: Query on GC
Thanks for your reply. Does this looks ok. I am following kathy Sierra. Is there any other book you would recommend. pls see the diagram below ( attached)
- Attachments
-
- Untitled.png (122.33 KiB) Viewed 1968 times
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Query on GC
No, like this:
Which book are you following?If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Mon Jan 27, 2020 11:41 am
- Contact:
Re: Query on GC
Kathy Sierra. Is there any other book you would recommend. So what should be the answer. No objects available for GC after line 1
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Query on GC
Answer is 1. There is no reference pointing to the first object at the end of line 1.
We recommend this:
https://www.amazon.com/gp/product/B07H6 ... nkCode=as2
We recommend this:
https://www.amazon.com/gp/product/B07H6 ... nkCode=as2
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Mon Jan 27, 2020 11:41 am
- Contact:
Re: Query on GC
Thank you
Who is online
Users browsing this forum: Google [Bot] and 102 guests