answersLogoWhite

0

What are parameters in java?

Updated: 8/10/2023
User Avatar

Wiki User

13y ago

Best Answer

A parameter or an argument is a value that is passed to a method so that the method can use that value in its processing.

Ex:

public String getName(String x){

return "Mr. " + x;

}

Here the method just prefixe's a Mr. with the value that is being passed to the method getName. The value X can be termed a parameter or an argument

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

In languages like Java and C,programs are organized into function. The main function is called by the startep code, and it, in turn calls other functions. The information passed explicitly to a function are the parameters.

Most modern languages use "data hiding" to increase reliability. A function can only change a parameter if it has access to the address of the parameter. That is, if you create a function addone and pass the parameter glop to the function, the function gets a copy og glop, changes the value of that copy, and when the function complete, the original glop trmains unchanged,

It rakes CPU cycles to do data hiding, and so not every language does it. Fortran has remained popular with scientists and engineers for 60 years because it can be lightning fast since, among other things, it doesn't do

data hiding. It still uses parameters, though, in statemebts like WRITE (3, 1H1) which says to print on device 3 the single character "1". (On an IBM 1130 running FORTRAN IV, that set a form feed command to the line printer).

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A parameter or an argument is a value that is passed to a method so that the method can use that value in its processing.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are parameters in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you define multiple parameters for one method in java?

The formal Java Language Specification does not list a hard limit on the number of formal parameters allowed. Generally, if you're worried that you might "run out" of parameter spaces, you will probably want to redesign your method.


Can you overload the constructor in java true or false?

Yes, you can have more than one constructor with a different set of parameters.


Is it possible to define two methods that have the same name but different parameters?

Yes. It is called Method Overloading in Java


How do you overload static methods in java?

Just create two methods with the same name, but with different types or numbers of parameters.


What is the definition of method overloadind in java?

That means you have two (or more) methods with the same name, but with different signatures - that is, the number or types of parameters are different. The compiler will automatically choose the correct method, according to the parameters provided.


Does passing static strings as parameters to a method create a copy of the String or passes its reference?

Java always follows a pass by value approach.


What is task of main method in Java?

All applications must start their execution from somewhere. In java that is the main method of a class.


Why java is not a complete object oriented language?

Java is not a completely object oriented language, because not all values in Java are Objects. For example, the basic numeric types such as int, long, double, etc., are not objects and need to be "boxed" into objects in order to pass them as Object parameters or call methods on them.


What is the methods with the parameters of an AWT?

AWT (Abstract Window Toolkit) is a top-level Java package. Listing out the hundreds or thousands of methods would be a waste of effort. See the related link below for the Java documentation on the AWT package.


Can you have more than 1 constructor in a class?

Yes. At least in Java, that's possible, as long as the constructors have a different number, or different types of, parameters.


How can you allocate memory dynamically in Java?

To give java more memory there are a series of steps to follow. To start, go to the computer's control panel, select programs, then go to java settings. This should initiate the Java control panel to pop up. Click on the Java tab followed by the view button. Click on the "runtime parameters" and input the specifics desired. Once finished hit okay then apply and it should increase the memory on your Java.


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.