This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "thread question" Watch "thread question" New topic
Author

thread question

shoba veran
Greenhorn

Joined: Apr 30, 2002
Posts: 9
hi guys:
one of my friend ask this question to me please give me the answer of this question and explanation
thax
// When matchXY method will retrurn true?


shoba
Amir Ghahrai
Ranch Hand

Joined: Jun 19, 2002
Posts: 110
I don't see any relevance of this question to threads..... are the methods supposed to be synchronized?
as it stands, the program returns true when run, without calling setXY(). the static variables x and y are set to their default values of 0.
since you are only calling matchXY(), then both x and y are equal so it returns true!
am I missing something here
[ July 13, 2002: Message edited by: Amir Ghahrai ]
[ July 13, 2002: Message edited by: Amir Ghahrai ]
[ July 13, 2002: Message edited by: Amir Ghahrai ]

Amir
nupur dhawan
Ranch Hand

Joined: Jun 26, 2002
Posts: 71
Shoba,
i totally agree with Amir. you might want to go through the code again and check if you have missed something....as your question pertaining to threads , seems no relevance here with this particular code snippet...therefore it comes across as a question , about static variables being initialised to 0 , hence being equal , when the method matchXY() is called , which in turn returns true !!!


Nupur. <br />SCJP2.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: thread question
 
Similar Threads
passing on values from method to method
Syntax for mapping a var to a method
how to call object in another class?
Enthuware question doubt
Question about sunchronized of thread