-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverload_constructor.java
More file actions
47 lines (37 loc) · 957 Bytes
/
overload_constructor.java
File metadata and controls
47 lines (37 loc) · 957 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
39
40
41
42
43
44
45
46
47
package com.company;
class MyMainEmployees1 {
private int id;
private String name;
public MyMainEmployees1(int id, String name) {
this.id = id;
this.name = name;
}
public MyMainEmployees1(int id) {
this.id = id;
}
public MyMainEmployees1(String name) {
this.name = name;
}
public MyMainEmployees1() {
this.id = 0;
this.name = "Your-name-Here";
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class overload_constructor {
public static void main(String[] args) {
MyMainEmployees1 m1=new MyMainEmployees1(12,"Rahul");
System.out.println(m1.getId()+" "+m1.getName()+" "+m1.getClass());
}
}