Introduction

In this blog, I will explain about Overloading Constructor in Java. It is effortless in Java Programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3
Simple program
  1. class overlo {
  2. double x, y;
  3. overlo(double a, double b) {
  4. x = a;
  5. y = b;
  6. }
  7. public void squ() {
  8. System.out.println("The Area of Square : " + (x * x));
  9. }
  10. public void rec() {
  11. System.out.println("The Area of Rectangle : " + (x * y));
  12. }
  13. public void cir() {
  14. System.out.println("The Area of Circle : " + (3.14 * x * x));
  15. }
  16. public static void main(String arg[]) {
  17. overlo t;
  18. t = new overlo(4, 4);
  19. t.squ();
  20. t = new overlo(5, 6);
  21. t.rec();
  22. t = new overlo(2, 3);
  23. t.cir();
  24. }
  25. }
Output
a