-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentDriver2.java
More file actions
43 lines (38 loc) · 1.17 KB
/
StudentDriver2.java
File metadata and controls
43 lines (38 loc) · 1.17 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
class UniversityStudent {
private static int count = 1;
private static final String UNIVERSITY = "Wiley mthree";
private String hometown;
private int rollNo;
private String name;
UniversityStudent() {
this.rollNo = count;
count++;
this.name = "";
this.hometown = "";
}
UniversityStudent(String name) {
this();
this.name = name;
}
UniversityStudent(String name, String hometown) {
this(name);
this.hometown = hometown;
}
public void display() {
System.out.println("Student name : " + this.name);
System.out.println("Student Roll No : " + this.rollNo);
System.out.println("Student Hometown : " + this.hometown);
System.out.println("Student University : " + UNIVERSITY);
System.out.println("");
}
}
public class StudentDriver2 {
public static void main(String[] args) {
UniversityStudent s1 = new UniversityStudent();
UniversityStudent s2 = new UniversityStudent("Bheru");
UniversityStudent s3 = new UniversityStudent("Yusuf", "Delhi");
s1.display();
s2.display();
s3.display();
}
}