answersLogoWhite

0


Best Answer

Method Parameters or Arguments are values that are passed to methods to aid the method in carrying out its intended functionality.

Ex:

public int add() {}

The above method is named "add" because it is supposed to add a few numeric values. But what will this method add? It needs input values that need to be added. Look at the below declaration

public int add(int a, int b) {}

This looks better because now we know that, this method is supposed to add the two numbers that are passed to it.

Here "a" and "b" are the parameters to the method

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the purpose of a method parameter?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is constructor overloading same as method overloading.yes or no. explain?

yes,because in constructor overloading constructor have same and different parameter list. In method overloading method have same name and different parameter list.


What do parameters and return values have to do with methods?

Parameters and return values are a major part of methods. When defining a method, you must include information about the data types of the return value and the parameters. An example of a method definition is this: public int getSumOfNumbers( int number1, int number2, int number3 ) { return ( number1 + number2 + number3 ); } The word "int" right after the word "public" is the return type. It describes what data type will be returned by the method. In this case, it was int, or integer. The sequence of words in between the parantheses, "int number1, int number2, int number3", is the parameter list. Each of the phrases separated by a comma in the parameter list is a parameter. The first word - in this case "int" - is the data type of the parameter. It describes what type of variable the parameter will be. The second word - "number1", "number2", or "number3" - is the name of the parameter. Every parameter must have a data type and a name, and every method must have a return type: even a method that returns nothing. For example: public void evaluateNumber(int number) { if ( number > 0 ) { System.out.println( number + " is positive." ); } else if ( number < 0 ) { System.out.println( number + " is negative." ); } else { System.out.println( number + " is zero." ); } } When a method does not return data, its return type must be defined as void, as it is above.


What is an actual parameter?

A formal perimeter refers to an identifier that is used in a method to stand for the value that is passed into the method by a caller. An actual perimeter on the other hand refers to the actual value that is passed into the method by a caller.


What is direct FM generation?

direct fm generation is a method of generation of fm signal directly with the help of parameter variation method. in this method we use some of the devices which converts the variation in voltage to variation in frequency such as varactor diode.


What is the data type of the parameter of the second version of the method?

Given that you haven't specified the method in question it is impossible to say what the parameter's data type would be. However, in statically typed languages such as Java, the method's signature will tell you specifically which data type is to be expected: void f (int x) { // expects an argument of type int // ... } void f (float x) { // expects an argument of type float // ... }

Related questions

Is constructor overloading same as method overloading.yes or no. explain?

yes,because in constructor overloading constructor have same and different parameter list. In method overloading method have same name and different parameter list.


How do you specify an optional parameter in a method?

You need to use the reserved word params.


What is the use of the parameter in java?

A parameter is a variable that is passed to a method. It is not specific to Java, and is used in almost all programming languages. The parameter is used by the method in whatever way that it wants. Example: public void add(int x, int y) { return x + y; } In this case, the parameters are two integers, x and y. They are passed to the method 'add' which returns the sum of the parameters.


What is the purpose of Imore parameter at the end of a command line?

It lists information one screen at a time


What boot parameter would you use to begin an FTP installation?

You would want to use Askmethod or method.


What is the difference between ref and out parameters?

Output parameters are similar to reference parameters, except that they transfer data out of the method rather than into it. Reference parameter copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the argument.


What is the main purpose of the scientific method?

The main purpose of the scientific method is to test ideas


What is the purpose of passing parameters by pointers?

There are two ways to pass parameters to a method. 1) Pass by value 2) Pass by reference.(i.e. pass by pointers). For here, I would say, whenever you required to change the properties/value of the parameter by the method you called you should the approach (2). ie. pass by pointers.


What do parameters and return values have to do with methods?

Parameters and return values are a major part of methods. When defining a method, you must include information about the data types of the return value and the parameters. An example of a method definition is this: public int getSumOfNumbers( int number1, int number2, int number3 ) { return ( number1 + number2 + number3 ); } The word "int" right after the word "public" is the return type. It describes what data type will be returned by the method. In this case, it was int, or integer. The sequence of words in between the parantheses, "int number1, int number2, int number3", is the parameter list. Each of the phrases separated by a comma in the parameter list is a parameter. The first word - in this case "int" - is the data type of the parameter. It describes what type of variable the parameter will be. The second word - "number1", "number2", or "number3" - is the name of the parameter. Every parameter must have a data type and a name, and every method must have a return type: even a method that returns nothing. For example: public void evaluateNumber(int number) { if ( number > 0 ) { System.out.println( number + " is positive." ); } else if ( number < 0 ) { System.out.println( number + " is negative." ); } else { System.out.println( number + " is zero." ); } } When a method does not return data, its return type must be defined as void, as it is above.


What exactly is println?

It is a method in System.out that prints the parameter to the screen. i.e. System.out.println("Hello World"); // prints Hello World.


What method is used to retrieve the value associated to the parameter name provided within the init-param?

getServletConfig().getInitParameter(paramName);


Is A query that prompts for input whenever it is run is a run-time query?

It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.