Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with parametarized method

Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with parametarized method

Program
import java.util.*;
class Factorial
{
    int n;
    Factorial()
    {
        Scanner s=new Scanner(System.in);
        System.out.println("Enter n value : ");
        n=s.nextInt();	
    }
    void fact(int x,int f)
    {
    
        for(x=1;x<=n;x++)
        {
            f=f*x;
        }
        System.out.println(f);
    }
}
public class Main
{
    public static void main(String args[])
    {
        Factorial ff=new Factorial();
        ff.fact(1,1);
    }
}


Output:

Enter n value : 5
120

Constructors In Java



More Questions


122 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with no parametarized method
123 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with parametarized method
124 . Write a Java-program to print Factorial Number program using no parametarized constructor with return type with no parametarized method
125 . Write a Java-program to print Factorial Number program using no parametarized constructor with return type with parametarized method
126 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with no parametarized method
127 . Write a Java-program to print Factorial Number program using parametarized constructor with no return type with parametarized method
128 . Write a Java-program to print Factorial Number program using parametarized constructor with return type with no parametarized method
129 . Write a Java-program to print Factorial Number program using parametarized constructor with return type with parametarized method
130 . Write a Java-program using this.(dot)
131 . Write a Java-program with out using this()
132 . Write a Java-program with using this()