***** 1. What is parameter and non - parameter in java?
Parameter
✓ parameter in Java is a variable that is declared inside the parentheses of a method or constructor
✓ It is used to receive values (called arguments) when the method or constructor is invoked.
✓ Parameters allow methods to be dynamic and reusable, because they can accept different input values at runtime.
Examples:
void add(int a, int b)
{ // a and b are parameters.
System.out.println(a + b);
}
Non - Parameter
✓ Non-parameter method or constructor in Java is one that does not take any input values.
✓ It has empty parentheses and performs its task using fixed logic or by accessing instance variables directly.
✓ Non-parameter methods are useful when no external input is required.
Example:
void showMessage()
{ // no parameters
System.out.println("Welcome to Java!");
}
**
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)