Data is passed to a function “explicitly” whereas a method is “implicitly passed” to the object for which it was called.
Please could you explain the difference between these two ways of passing data? An example in java or c# would help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The language Java and Python are good examples in illustrating this. In Python, the object is passed explicitly whenever a method of a class is defined:
Here, the object
selfis passed explicitly as the first argument. This means thatis effectively the same as calling
method(e, 3, 4)ifmethodwere a function.However, in Java the first argument is not explicitly mentioned:
In Java, it would be:
The instance
eis passed tomethodas well but the special variablethiscan be used to access it.Of course, for functions each argument is passed explicitly because each argument is mentioned in both the function definition and where the function is called. If we define
then we can call it with
func(1, 2, 3)which means all arguments are explicitly passed.