Sample method to find factorial

Sample method to find factorial


import java.io.*;
class Factorial{
  public static void main(String[] args) {
  try{
  BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("enter the number");
  int a= Integer.parseInt(object.readLine());
  int fact= 1;
  System.out.println("Factorial of " +a+ ":");
  for (int i= 1; i<=a; i++){
  fact=fact*i;
  }
  System.out.println(fact);
  }
  catch (Exception e){}
  }
}

Sample program for aggregation

Sample program for aggregation


class MainTest 
{
Test1 t1;
Test2 t2;
Test3 t3;
MainTest(Test1 t1,Test2 t2,Test3 t3)
{
this.t1=t1;
this.t2=t2;
this.t3=t3;
}
void disp()

simple program methods overloading vs hierarchical inheritance

simple program methods overloading vs hierarchical inheritance

class Heroin
 {
int Rating()
{ return 0; }
}
class Anuska extends Heroin 
{
int Rating()