-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_constructor.java
More file actions
52 lines (43 loc) · 1.04 KB
/
Practice_constructor.java
File metadata and controls
52 lines (43 loc) · 1.04 KB
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
48
49
50
51
52
package com.company;
class MainEmployees
{
private int id;
private String name;
private int salary;
public MainEmployees(int id, String name, int salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
public MainEmployees() {
this.id = 1;
this.name = "Rahul";
this.salary = 10000;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
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 Practice_constructor {
public static void main(String[] args) {
MainEmployees m1=new MainEmployees();
System.out.println(m1.getId());
System.out.println(m1.getName());
System.out.println(m1.getSalary());
}
}