• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Parameters - Constructors

 
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, back when I was learning about OOP, I was a bit confused between Arguments vs Parms.

If I remember correctly, parms where passed in and args are returned.

My question relates to Constructors.  In the following code snippet (taken from CodeAcademy):




So, the literal "lemonade" is passed to the variable product and then is assigned to productType?

I think that I finally understand so I'm basically seeking confirmation.

 
Sheriff
Posts: 17127
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The two are often used interchangeably. There are “Formal Parameters” which are the things declared in the method header. They are the “abstract” representations of the values that are passed to the method. Then you have “Actual Parameters” which are, of course, the actual values passed when you call the method. The term “arguments” is often used to refer to the actual parameters. That is, you’d say “I call the System.out.println() method with a String argument.” However, it’s not uncommon for people to say “parameters” when they’re talking about the actual parameters (rather than the formal parameters).

One could also say that a return statement can have an argument. That’s the expression that follows the word “return,” in which case the value that the expression evaluates to is what will be returned to the caller of the method. This use of “argument” is not very common though, as far as I can tell.

 
Marshal
Posts: 76453
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Royale Summers wrote:. . . If I remember correctly, parms where passed in and args are returned.

'Fraid not. What you write in the () after the method/construtor name is called parameters; what you send to that method/constructor from elsewhere is called arguments. The terms may vary in differeent languages. What you return is called the return value. Constructors and void methods don't have return values.

Please don't abbreviate words like that: look here. Remember some readers don't have good grasp of English and may not readily be abbble to expand such abbreviations.

. . . So, the literal "lemonade" is passed to the variable product and then is assigned to productType?  . . .

Yes, that is correct. Constructors aren't methods; they only look a bit like methods. Beware of writing this sort of thing, slightly changed from the above code:-That void changes the constructor to a method, an error it is very easy to get confused about.
 
Junilu Lacar
Sheriff
Posts: 17127
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Royale Summers wrote:
So, the literal "lemonade" is passed to the variable product and then is assigned to productType?


Not quite the right way to say it. Formally, you’d say something like: The literal “lemonade” is passed to the constructor and assigned to the product parameter which is then assigned to the productType field (or member variable).

You could also say the literal “lemonade” is passed as an argument to the Store constructor...
 
Junilu Lacar
Sheriff
Posts: 17127
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In everyday conversations, you’ll hear things like this:

“What arguments did you pass to that method?” (Here “arguments” refers to the actual parameters)

“What parameters did you call the method with?” (Here “parameters” refers to the actual parameters, also “arguments”)

“What parameters does that method take?” (Here “parameters” most likely refers to the formal parameters declared in the method header

“What does that method return?” — the person wants to know either the type of the value the method returns or the actual value. Depends on the context.
 
Royale Summers
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu –

Thanks for the correction on the verbiage to include the definitions . "Abstract" representation made me think of Pointers and Absolute versus Relative.
Thank you for reminding me that not all would be familiar with abbreviations although it actually has args in all main methods.  

Campbell –

Thanks for the input on Constructor versus Method.  I was aware of the difference.  Our Bootcamp never mentioned the Default Constructor though…

Although I appreciate the information, to help in my learning, did I get the 'flow' of the literal string "lemonade" as it 'moved' around correct?

Thanks.
 
Junilu Lacar
Sheriff
Posts: 17127
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Royale Summers wrote:did I get the 'flow' of the literal string "lemonade" as it 'moved' around correct?


More or less, yes.
 
Royale Summers
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu -

I'm going to say that response is "ambiguous."

Remember that I seeking to be the best that I can be so I need a 'yes' or 'no' and if 'no' what am I getting wrong.

Don't worry about hurting my feelings...thanks!
 
Junilu Lacar
Sheriff
Posts: 17127
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"More or less" because the concept is right but the way you said it was not quite, as I already pointed out previously.
 
Royale Summers
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu -

Okay, thanks for the clarification that I was right but not articulating it correctly.

 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic