• Concept of defining multiple constructors within the same class by changing the data types of the parameters is known as constructor overloading.
package com.instanceofjavaforus;

public class ConstructorOverloading {

int a,b,c;

ConstructorOverloading(){
    this(1);
}

ConstructorOverloading(int a){
    this(a,2);
}

ConstructorOverloading(int a, int b){
    this(a,b,3);
}

ConstructorOverloading(int a, int b,int c){
this.a=1;
this.b=2;
this.c=3;
System.out.println(a+""+b+""+c);
}
   
public static void main(String args[]){
   
    ConstructorOverloading obj=new ConstructorOverloading();
   
   }
   
}


OutPut:
1 2 3

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu