Created
August 18, 2020 08:11
-
-
Save neer2808/622907ab90962f417fb85291dd0a89c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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