-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReturnAndPassObject.java
More file actions
38 lines (34 loc) · 836 Bytes
/
ReturnAndPassObject.java
File metadata and controls
38 lines (34 loc) · 836 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
package IS
class PrgStudent
{
int rollno;
String name;
PrgStudent(int rollno, String name){
this.rollno = rollno;
this.name = name;
}
}
class PrintJob
{
void printStudentInfo(int rollno, String name){
rollno++;
System.out.println("Rollno "+rollno);
System.out.println("Name "+name);
}
void printStudentInfo(PrgStudent student){
student.rollno++;
System.out.println("Rollno "+student.rollno);
System.out.println("Name "+student.name);
}
}
public class ReturnAndPassObject {
public static void main(String[] args) {
PrgStudent studentObj = new PrgStudent(1001, "Ram");
PrintJob job = new PrintJob();
//int x = 1001;
//job.printStudentInfo(x, "Ram");
//System.out.println("Now New Rollno is "+x);
job.printStudentInfo(studentObj);
System.out.println("Now New Rollno is "+studentObj.rollno);
}
}