- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreeconstructor.java
More file actions
Latest commit
31 lines (25 loc) · 752 Bytes
/
Copy paththreeconstructor.java
File metadata and controls
31 lines (25 loc) · 752 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
packagejavatest;
classStudent {
Stringname="sharda";
intage=20;
publicStudent() {
System.out.println("Default constructor called "+name+" "+age);
}
publicStudent(Stringname, intage) {
this.name=name;
this.age=age;
System.out.println("Parameter constructor called "+name+" "+age);
}
publicStudent(Studentother) {
this.name=other.name;
this.age=other.age;
System.out.println("Copy constructor called "+name+" "+age);
}
}
publicclassthreeconstructor {
publicstaticvoidmain(String[] args) {
newStudent();
Students=newStudent("ashira ", 222);
Students1=newStudent(s);
}
}