What is the scope of a method parameter?
Advertisements
प्रश्न
What is the scope of a method parameter?
दीर्घउत्तर
Advertisements
उत्तर
- The scope of a method parameter in Java is limited to the method in which it is declared. Method parameters are treated as local variables and can be accessed and used only within the body of that method.
- When a method is called, the arguments passed to it are assigned to the corresponding parameters. These parameters can then be used to perform calculations, process data, or execute other operations within the method.
- A method parameter cannot be accessed directly outside the method in which it is declared. Its scope extends from its declaration in the method's parameter list to the end of the method body.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - SHORT ASSIGNMENTS [पृष्ठ १३६]
