forked from manav88/javaNS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththisexm.java
More file actions
31 lines (26 loc) · 721 Bytes
/
thisexm.java
File metadata and controls
31 lines (26 loc) · 721 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
class Student {
int rollno;
String name, course;
float fee;
Student(int rollno, String name, String course) {
this.rollno = rollno;
this.name = name;
this.course = course;
}
Student(int rollno, String name, String course, float fee) {
// reusing constructor
this(rollno, name, course);
this.fee = fee;
}
void display() {
System.out.println(rollno + " " + name + " " + course + " " + fee);
}
}
class thisexm {
public static void main(String args[]) {
Student s1 = new Student(111, "ankit", "java");
Student s2 = new Student(112, "sumit", "java", 6000f);
s1.display();
s2.display();
}
}