हिंदी

What are method parameters used for in Java?

Advertisements

प्रश्न

What are method parameters used for in Java?

विस्तार में उत्तर
Advertisements

उत्तर

Method parameters in Java are used to pass values or data from a calling method to the method being called. They allow a method to receive input values and perform specific operations using those values.

The main purposes of method parameters are:

  1. Passing Data: Parameters allow values to be passed from one method to another for processing.
  2. Performing Operations: They enable methods to perform calculations or other operations using the supplied values.
  3. Improving Flexibility: Parameters allow the same method to work with different input values without changing its code.
  4. Code Reusability: They help reuse a method multiple times with different arguments, reducing code duplication.

Thus, method parameters make Java methods more flexible, efficient, and reusable by allowing them to accept and process different input values.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - SHORT ASSIGNMENTS [पृष्ठ १३६]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 6 Variables and Expressions
SHORT ASSIGNMENTS | Q 35. (ii) | पृष्ठ १३६
Advertisements
Share
Notifications



      Forgot password?
Use app×