Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock quesiton :output is confusing 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 » Programmer Certification (SCJP/OCPJP)
Bookmark "mock quesiton :output is confusing" Watch "mock quesiton :output is confusing" New topic
Author

mock quesiton :output is confusing

Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432


output :82
why it is not coming 92?


SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Primitives are passed to methods as a values - this is the first point.
The second one is that you are shadowing the instance variable "squares" with method parameter named the same "squares".

Try changing the method argument from "squares" to "squares2" and see what happens:




OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

Pedro Kowalski wrote:
The second one is that you are shadowing the instance variable "squares" with method parameter named the same "squares".

yeah got it,
thanks pedro.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

No problem mate :-) Glad it helped!
 
 
subject: mock quesiton :output is confusing
 
Similar Threads
Incrementor operator
Can some one help me ?
pass by value
a confused concept
JQ+ Arrays[0]++