Introduction
In this blog I will explain about Overloading Constructor in Java. It is very simple in Java Programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3
Simple program
- class overlo
- {
- double x,y;
-
- overlo(double a, double b)
- {
- x = a;
- y = b;
- }
-
- public void squ()
- {
- System.out.println("The Area of Square : "+(x*x));
- }
-
- public void rec()
- {
- System.out.println("The Area of Rectangle : "+(x*y));
- }
-
- public void cir()
- {
- System.out.println("The Area of Circle : "+(3.14*x*x));
- }
-
- public static void main(String arg[])
- {
- overlo t;
-
- t = new overlo(4,4);
- t.squ();
-
- t = new overlo(5,6);
- t.rec();
-
- t = new overlo(2,3);
- t.cir();
- }
- }
Output