मराठी

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)

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Encapsulation - Exercises [पृष्ठ १४९]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 6 Encapsulation
Exercises | Q 4. | पृष्ठ १४९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×