• Post Reply Bookmark Topic Watch Topic
  • New Topic

Local and Global Scope in Java  RSS feed

 
Aakash Goplani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was solving MCQs and came across this problem. I am not able to understand the output of 3rd SOP statement



Can you help me to understand this one?

Thanks.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get a little sheet of paper and draw squares on labelled t and this. Use a pencil, so you can delete the old values as they change. Put the values of x and y on each. When you get to line 11, which y are you changing? When you get to line 24, which y are you printing?
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have been moved to the “beginning” forum because you started off in the wrong place.
The title of your question is confusing; neither y is in global scope and maybe neither y is in local scope. The variable t is in local scope however.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!