Skip to content

Instantly share code, notes, and snippets.

@neer2808
Created August 18, 2020 08:11
Show Gist options
  • Save neer2808/622907ab90962f417fb85291dd0a89c3 to your computer and use it in GitHub Desktop.
Save neer2808/622907ab90962f417fb85291dd0a89c3 to your computer and use it in GitHub Desktop.
class emp
{
int empid;
String name;
public emp() {
}
public emp(int empid, String name) {
this.empid = empid;
this.name = name;
}
public void show()
{
System.out.println(empid + " "+ name);
}
}// end of the class
public class constructorDemo1 {
public static void main(String[] args) {
emp obj1 = new emp();
//emp obj2 = new emp(90,"bbb");
obj1.show();
//obj2.show();
}
}
// can we overload constructor
// yes we can overload constructor
// 1) by providing different no of arguments
// emp(int)
// emp(int, int)
// emp(int,, int , int )
//// 2) by providing different types of arguments
//
// emp(int)
// emp(String)
// emp(int, String)
// emp(String, int)
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment