File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Conflicting statements for arguments and parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Conflicting statements for arguments and parameters" Watch "Conflicting statements for arguments and parameters" New topic
Author

Conflicting statements for arguments and parameters

Robin Kumar
Greenhorn

Joined: Mar 07, 2013
Posts: 13
I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11475
    
  16

umm....WHAT book are you talking about?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Robin Kumar
Greenhorn

Joined: Mar 07, 2013
Posts: 13
fred rosenberger wrote:umm....WHAT book are you talking about?


SCJP Sun Certified Programmer for Java 6-0071591060
Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: However when you call a method, following the previous example it would be:



So basically, parameters are just placeholders for the actual data that are going to be inserted when the method gets called; Arguments, are the data inserted when the method got called.
Hope it cleared up things,

have a nice preparation for the exam!

OCAJP 7, OCPJP 7
Robin Kumar
Greenhorn

Joined: Mar 07, 2013
Posts: 13
Nick Widelec wrote:
Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: When you call a method, following the previous example it would be:



Hope it cleared up things,

have a nice preparation for the exam!



thanks for your effort but the book says the opposite in many places... kindly refer the pages i have mentioned and explain whether its an error or is there something that i'm not able to understand?
Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Robin Kumar wrote:
Nick Widelec wrote:
Robin Kumar wrote:I am currently done with the first three chapters of the book but i have come across three to four instances where its very confusing to differentiate what exactly is a an argument or a parameter.... kindly read page number 41(1st two lines),46(Definition of argument and parameter) & 249(1st two lines) of the book and please explain what the authors intended to say??


Ehy Robin,


Parameters: When you declare a method, like for example:



Arguments: When you call a method, following the previous example it would be:



Hope it cleared up things,

have a nice preparation for the exam!



thanks for your effort but the book says the opposite in many places... kindly refer the pages i have mentioned and explain whether its an error or is there something that i'm not able to understand?


Ehy man, I don't have your book but I can guarantee you that it is in this way.

Check out wikipedia then if still in doubt: http://en.wikipedia.org/wiki/Parameter_%28computer_programming%29#Parameters_and_arguments

Here the wikipedia quote:

These two terms parameter and argument are sometimes loosely used interchangeably, and the context is used to distinguish the meaning. The term parameter (sometimes called formal parameter) is often used to refer to the variable as found in the function definition, while argument (sometimes called actual parameter) refers to the actual value passed. To avoid confusion, it is common to view a parameter as a variable, and an argument as a value.



Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4461
    
    8

Not everyone has the book!

To the extent that there's an official terminology, I'd refer to the Java Language Specification. That uses parameter for the specification:

JLS 8.4.1
The formal parameters of a method or constructor, if any, are specified by a list of comma-separated parameter specifiers. Each parameter specifier consists of a type (optionally preceded by the final modifier and/or one or more annotations) and an identifier (optionally followed by brackets) that specifies the name of the parameter.

and arguments for the actual values:

JLS 15.12
A method invocation expression is used to invoke a class or instance method.

MethodInvocation:
MethodName ( ArgumentListopt )
Robin Kumar
Greenhorn

Joined: Mar 07, 2013
Posts: 13
thank you all for your kind support...
Robin Kumar
Greenhorn

Joined: Mar 07, 2013
Posts: 13
Some of the statements of the book are:

"Method arguments are the variable declarations that appear in between the parentheses in a method declaration."

********************************************************

"arguments: The things you specify between the parentheses when you're invoking a method:

doStuff("a", 2); // invoking doStuff, so a & 2 are arguments

parameters :The things in the method's signature that indicate what the
method must receive when it's invoked:

void doStuff(String s, int a) { } // we're expecting two
// parameters: String and int"

********************************************************

"Overloaded methods
❑Must have different argument lists
❑May have different return types, if argument lists are also different
❑May have different access modifiers
❑May throw different exceptions"

********************************************************


"With respect to the method it overrides, the overriding method
❑Must have the same argument list.
❑Must have the same return type, except that as of Java 5, the return type
can be a subclass—this is known as a covariant return.
❑Must not have a more restrictive access modifier.
❑May have a less restrictive access modifier.
❑Must not throw new or broader checked exceptions.
❑May throw fewer or narrower checked exceptions, or any
unchecked exception."

These are some of the confusing statements i found in the book.... can anyone explain what Kathy Sierra and Bert Bates are trying to accomplish??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conflicting statements for arguments and parameters