-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructorOverload.java
More file actions
38 lines (38 loc) · 990 Bytes
/
Copy pathConstructorOverload.java
File metadata and controls
38 lines (38 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Constructor{
private String name;
private int id;
private int salary;
public Constructor(){
System.out.println("Welcome........");
}
public Constructor(String myname,int myid,int mysalary){
name=myname;
id=myid;
salary=mysalary;
System.out.println("my name is:"+name+"\nmy id is:"+id+"\nmy salary is:"+salary);
}
public void setname(String name){
this.name=name;
}
public String getname(){
return name;
}
public void setid(int id){
this.id=id;
}
public int getid(){
return id;
}
public void setsalary(int salary){
this.salary=salary;
}
public int getsalary(){
return salary;
}
}
public class ConstructorOverload{
public static void main(String[] args) {
Constructor y=new Constructor();
Constructor y1=new Constructor("tanmay sanjay gaidhani",113,234235);
}
}