programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Devaka Cooray
• Liutauras Vilda
• Jeanne Boyarsky
• Bear Bibeault
Sheriffs:
• Paul Clapham
• Knute Snortum
• Rob Spoor
Saloon Keepers:
• Tim Moores
• Ron McLeod
• Piet Souris
• Stephan van Hulst
• Carey Brown
Bartenders:
• Tim Holloway
• Frits Walraven
• Ganesh Patekar

# how does this n3.p.p.id work ?

Ranch Hand
Posts: 48
I am not getting how does this code work - especially the n3.p.p.id part - and tracking the objects seems difficult to me. Can anyone help me out please ?  thanks
ch3q10.png

Marshal
Posts: 65034
247
Please avoid screenshots and please always tell us where the material comes from. Is it another question from Boyarsky and Selikoff? Please tell us the book title and page number.
Did you run the code? I think the way to solve that sort of question is to write down on paper what each object is, and what its fields point to.

Remember that is very poor quality code, which should only ever be seen in cert. exams or cert. exam revision books

Greenhorn
Posts: 1

Md Zuanyeed Kamal wrote:I am not getting how does this code work - especially the n3.p.p.id part - and tracking the objects seems difficult to me. Can anyone help me out please ?  thanks

Hi,

Is the answer 1 i.e option A.

If it is here's the explaination :

n2's p variable is pointing to n1 and n3's p variable is pointing to n2.

Now we have the expression n3.p.p.id...

As per above explaination, n3.p is pointing to n2 and our expression resultant become :-
n2.p.id

Now n2.p is pointing to n1, which make our expression to  become
n1.id

And n1.id is 1 i.e option A.

Hope this will help...