-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConst.java
More file actions
59 lines (43 loc) · 1.22 KB
/
Const.java
File metadata and controls
59 lines (43 loc) · 1.22 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
53
54
55
56
57
58
59
class Const{
int rno;
String name;
int std;
Const(){
System.out.println("STARTING : Default Constructor:");
System.out.println(rno+ " "+ name + " "+ std);
rno = 1;
name = "Akshat";
std = 10;
System.out.println(rno+ " "+ name + " "+ std);
System.out.println("ENDING : Default Constructor:");
}
Const(int r,String n, int s){
System.out.println("STARTING : Parameter Constructor:");
System.out.println(rno+ " "+ name + " "+ std);
rno = r;
name = n;
std = s;
System.out.println(r+ " "+ n + " "+ s);
System.out.println("ENDING : Parameter Constructor:");
}
Const(Const s){
System.out.println("STARTING : para/Copy Constructor:");
System.out.println(rno+ " "+ name + " "+ std);
rno = s.rno;
name = s.name;
std = s.std;
System.out.println(rno+ " "+ name + " "+ std);
System.out.println("ENDING : para/Copy Constructor:");
}
void showdetails(){
System.out.println(rno+ " "+ name + " "+ std + " "+ this);
}
public static void main(String args[]){
Const s1 = new Const();
Const s2 = new Const(2,"Neha",10);
Const s3 = new Const(s2);
s1.showdetails();
s2.showdetails();
s3.showdetails();
}
}