-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStudent.java
More file actions
33 lines (27 loc) · 832 Bytes
/
Student.java
File metadata and controls
33 lines (27 loc) · 832 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
class Person { // removed 'public'
String name;
Person(String name){
this.name = name;
}
}
public class Student extends Person {
int rollNo;
String section;
Student(String name, int rollNo, String section){
super(name);
this.rollNo = rollNo;
this.section = section;
}
public void printDetails() {
System.out.print("Student Details: ");
System.out.println(this.name+ ", " + this.rollNo + ", " + section);
}
public static void main(String[] args) {
Students student1 = new Students("Robert", 1, "IX Blue");
Students student2 = new Students("Adam", 2, "IX Red");
Students student3 = new Students("Julie", 3, "IX Blue");
student1.printDetails();
student2.printDetails();
student3.printDetails();
}
}