This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Certification Results and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Certification Results
Bookmark "Threads" Watch "Threads" New topic


Sujatha Musunuri

Joined: Oct 23, 2007
Posts: 16

Just going through the sample questions got from web.
Can someone explain me the result of the following program, placed at:

The Answer for that question is F.

Thanks in advance.
Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
The code you provided will yeild the answer of 0 2 4 6 as mentioned by the option 'f'

Look at the main method.The first line created an array of size 4 and type Computation.
Now each element of the array is used to create a new object of computation by passing the index value of the array as parameter.
Thus we have 4 computation objects calling the constructor once for each.It also means we will have 4 instance variables of type isComplete,num and num is being shadowed by the local num in the constructor so,the global num is explicitly given the value passed by local num through the keyword 'this'.
When the start() is called it makes a call to run().here value of result is set.
lastly in the print statement(with the use of new for:each loop),the getResult is called which returns the value of result which is printed.

Hope this solves your query.

Sujatha Musunuri

Joined: Oct 23, 2007
Posts: 16
Hi Jitendra Jha,

I got it now...Thanks alot for your explanation.
It is sorta covered in the JavaRanch Style Guide.
subject: Threads
Similar Threads
tray icon is not displaying
How can i add tomcat server to Eclipse Galileo
electric cars faster than gas cars
IF strings are immutable why is the variable s appending and changing its obect
SCJD after the acquisition of Sun (by Oracle)