Advertisements
Advertisements
प्रश्न
Given the following program, identify the local variable, instance variable and argument variable.
importjava.util.*;
class Factor
{
int N;
void fnIsFactor(int f)
{
if (N%f =0)
{
System.out.print(f +" is a Factor of "+ N);
}
else
{
System.out.print(f + " is a Not a Factor of "+ N);}
}
}
void fnAllFactors()
{
int r = 0;
System.out.println("\n Factors of " + N);
for(r = 1; r <=N; r++)
{
if (N % r =0)
{
System.out.print(r + "");
}
}
}
void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter value for N :");
N = sc.nextInt();
System.out.println("Enter value for L :");
int L = sc.nextInt();
fnIsFactor(L);
fnAllFactors();
}
}अति संक्षिप्त उत्तर
Advertisements
उत्तर
N - instance variable
f - argument, formal variable
r - local variable
sc - object/variable of scanner class
L - local variable
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
