by Dinesh Thakur

 

class Rectangle

            {
                int l,b,a;
                Rectangle()
                    {
                        l=5;     
                        b=3;
                    }
           
                    Rectangle(int x)
                      {
                          l=x;
                          b=3;
                      }
                          Rectangle(int x,int y)
                             {
                                 l=x;
                                 b=y;
                             }
                                void GetArea()
                                 {
                                      a=l*b;
                                      System.out.println("Area of Rectangle is : "+a);
                                 }
                   }
                                      class Volume extends Rectangle
                                          {
                                      int h,v;
                                      Volume()
                                      {
                                          super();
                                          h=30;
                                      }
                                                 Volume(int x)
                                      {
                                          super(x);
                                          h=30;
                                      }
                                          Volume(int x, int y)
                                                        {
                                                            super(x,y);
                                                h=30;
                                            }
                                                Volume(int x, int y, int z)
                                                    {
                                                       super(x,y);
                                                   h=z;
                                                }
                                                   int getVolume()
                                                      {
                                                         v=l*b*h;
                                                         return(v);
                                                       }
                                 }
                                      class SuperClassEx
                                         {
                                                         public static void main(String args[])
                                               {
                                                    Volume Vol = new Volume();
                                                    Volume Vol1=new Volume(5);
                                                    Volume Vol2=new Volume(5,2);
                                                    Volume Vol3=new Volume(5,3,2);
                                                    System.out.println("Volume of First Rectangle is : "+Vol.getVolume());
                                                    System.out.println("Volume of Second Rectangle is : "+Vol1.getVolume());
                                                    System.out.println("Volume of Third Rectangle is : "+Vol2.getVolume());
                                                    System.out.println("Volume of Fourth Rectangle is : "+Vol3.getVolume());
                                               }
                                        }

Example of Super Method in Java