class TestSuper
{
	int i;
        long fact=1;
        void factFind(int n)
        {
        	for(i=1;i<=n;i++)
    		{
			fact=fact*i;
                }
	}

        void display()
	{
		System.out.println("\n\nFactorial is calculated from super class and it is "+fact);
        }
        void disp()
        {
 		System.out.println("\n\nThis is Super class");
 	}	
}
class TestSubOveride extends TestSuper
{
	void disp()
	{
		System.out.println("\n\n I am in subclass");
	}
        void doit()
        {
		disp();
		factFind(4);
		display();
		this.disp();
		super.disp();
        }
	public static void main(String args[])
	{
		TestSubOveride ob=new TestSubOveride();
 		ob.doit();
	}
}

Click here to go back.

Our aim is to provide information to the knowledge seekers.


comments powered by Disqus




Footer1