I know that explicit parameters are those that are listed within the parenthesis of method calls. I also know that formal parameters are the names of the parameters in the method heading.
In this code, does it make sense to call x both an formal and explicit parameter?
public int add(int x, int y) {
return x + y;
}
And if so, is there any case where you would have a formal parameter that is not an explicit parameter?
I'm trying to think of all the cases that seem to be possible -- formal explicit, formal implicit, actual explicit, and actual implicit. Are all of these possible and valid?
Not sure about it but I think this is correct:
In this code, does it make sense to call x both an formal and explicit parameter?
Yes, it's both formal and explicit.
is there any case where you would have a formal parameter that is not an explicit parameter?
this
is a formal implicit parameter.
We already addressed when they are explicit and implicit they will be actual when you will actually call the code.
add(1,2); // 1 and 2 are actual explicit parameters
"a".length(); // "a" is the actual implicit parameter