Query on GC

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
amittora29
Posts: 4
Joined: Mon Jan 27, 2020 11:41 am
Contact:

Query on GC

Post by amittora29 »

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

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Query on GC

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Query on GC

Post by admin »

You need to draw a diagram with references and objects. Then change the references after each statement.
Which book are you following?
If you like our products and services, please help us by posting your review here.

amittora29
Posts: 4
Joined: Mon Jan 27, 2020 11:41 am
Contact:

Re: Query on GC

Post by amittora29 »

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
Untitled.png (122.33 KiB) Viewed 1968 times

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Query on GC

Post by admin »

No, like this:
test.jpg
test.jpg (84.15 KiB) Viewed 1964 times
Which book are you following?
If you like our products and services, please help us by posting your review here.

amittora29
Posts: 4
Joined: Mon Jan 27, 2020 11:41 am
Contact:

Re: Query on GC

Post by amittora29 »

Kathy Sierra. Is there any other book you would recommend. So what should be the answer. No objects available for GC after line 1

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Query on GC

Post by admin »

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
If you like our products and services, please help us by posting your review here.

amittora29
Posts: 4
Joined: Mon Jan 27, 2020 11:41 am
Contact:

Re: Query on GC

Post by amittora29 »

Thank you

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 102 guests