-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHello.java
More file actions
76 lines (62 loc) · 1.74 KB
/
Copy pathHello.java
File metadata and controls
76 lines (62 loc) · 1.74 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class calculator{
private int rollno;
private String name;
private int marks;
// public int add(int i,int j)
// {
// int k = i + j;
// return k;
// }
public calculator(){
rollno = 5;
name = "titi";
marks = 58;
System.out.println("in default");
}
public calculator(int rollno, String name, int marks)
{
this.rollno = rollno;
this.name = name;
this.marks = marks;
}
public calculator(calculator obj) // copy constructor
{
this.rollno = obj.rollno;
this.marks = obj.marks;
this.name = obj.name;
System.out.println("in copy constructor");
}
public void setRoll( int roll){
rollno = roll;
}
public int getRoll(){
return rollno;
}
public void setName(String names){
name = names;
}
public String getName(){
return name;
}
public void setMark(int mark){
marks = mark;
}
public int getMarks(){
return marks;
}
}
public class Hello
{
public static void main(String args[]){
// calculat{
calculator tea = new calculator();
calculator cal = new calculator(12,"vic",56);
// cal.setRoll(12);
// cal.setName("james");
// cal.setMark(90);
System.out.println("Name " + ": " + "Roll no " + ": " + "Marks scores");
System.out.println(cal.getName() + " : " + cal.getRoll() + " : " + cal.getMarks());
calculator obj1 = new calculator(tea);
System.out.println(obj1.getName() + " +" + obj1.getRoll() + " +" + obj1.getMarks());
}
}