- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor.java
More file actions
Latest commit
43 lines (32 loc) · 949 Bytes
/
Copy pathconstructor.java
File metadata and controls
43 lines (32 loc) · 949 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
classmymainemployee {
Stringname;
intid;
publicmymainemployee(Stringmyname, intmyid) { // constructor me ham ek method defined kae dete hAI
// jiska nam same hota hai MAIN CLASS SE;;;
id = myid; // constructor means constuct karna
name = myname;
}
publicmymainemployee() {
id = 45;
name = "varad dhumale";
}
publicvoidsetname(Stringn) {
this.name = n;
}
publicStringgetname() {
returnname;
}
publicvoidsetid(inti) {
this.id = i;
}
publicintgetid() {
returnid;
}
}
publicclassconstructor {
publicstaticvoidmain(String[] args) {
mymainemployeevarad = newmymainemployee("varaddhumale", 20);
System.out.println(varad.getid());
System.out.println(varad.getname());
}
}