Define a method.Explain about parameterised and non parameterised methods with example program
Answers
Answer:
A program module( a part of the program) used simultaneously at different instances in a program specific task is known as method or function.
Explanation:
Parameterised methods are the methods which contain a list of variables with their respective data types, required by the function for internal computation passed during method call.
Eg :-
class factorial
{
public int fact(int x)
{
int f=0, i;
for( i=1;i<=x;i++)
f*=i;
return(f);
}
public static void main(String args[])
{
factorial ob = new factorial();
int n=5, m=8;
p=ob.fact(n);
System.out.println("factorial of "+n+"is"+p);
q=ob.fact(n);
System.out.println("factorial of "+m+"is"+q);
}
}
Non parameterised methods are the methods which does not contain a list of variables with their respective data types and the method does not receive any value during its call.
Eg :-
class factorial
{
public int fact(int x)
{
int f=1,n=5, i;
for( i=1;i<=x;i++)
f*=i;
System.out.println("factorial of "+ n+"is"+f);
}
public static void main(String args[])
{
factorial ob = new factorial();
ob.fact();
}
}
Answer:
A hygrometer is an instrument used to measure the amount of water vapor in air, in soil, or in confined spaces. Humidity measurement instruments usually rely on measurements of some other quantities such as temperature, pressure, mass, a mechanical or electrical change in a substance as moisture is absorbed.