Hi, Emi! So, first we have:
instance variable ns = 0 and static variable s = 0
When we call the constructor, we will have:
Alpha (100): if (s < ns) then s = ns and this.ns = ns
so: if (0 <100) then s = 100 and this.ns = 100
Alpha(50): now s = 100 because is static (updated above)
if (100 < 50) which is false. ns = 0 because the instance variable is 0.
Alpha(125): At this point, s = 100
if (100 < 125) then s = 125 and ns = 125. So here s is updated!
At this point, when we call System.out.println(), for all ref1, ref2, ref3 the value of s is 125 (remember s is static). For ref1, ns = 100, for ref2 ns = 0, and for ref3 ns = 125. I hope this helps you :) Roxy
upvoted 9 times
...
...
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
vic88
8 months agoDarGrin
1 year, 9 months agochuducanhchy
2 years, 5 months agocarloswork
2 years, 9 months agoEmiTanase
2 years, 10 months agoRoxyFoxy
2 years, 10 months ago