- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPersonStudent.java
More file actions
Latest commit
54 lines (51 loc) · 1.16 KB
/
Copy pathPersonStudent.java
File metadata and controls
54 lines (51 loc) · 1.16 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
publicclassPerson {
Stringname;
Person(Stringname)
{
this.name=name;
}
}
classStudentextendsPerson
{
StringCollegeName;
publicStudent(Stringname, StringCollegeName) {
super(name);
this.CollegeName = CollegeName;
}
}
classTeacherextendsPerson
{
intsalary;
Stringsubject;
publicTeacher(Stringname,intsalary, Stringsubject) {
super(name);
this.salary = salary;
this.subject = subject;
}
voiddisplay()
{
System.out.println(name+" "+salary+" "+subject);
}
}
classCollegeStudentextendsStudent
{
intyear;Stringmajor;
publicCollegeStudent(Stringname, StringcollegeName, intyear, Stringmajor) {
super(name, collegeName);
this.year = year;
this.major = major;
}
voiddisplay()
{
System.out.println(name+" "+CollegeName+" "+year+" "+major);
}
}
classPersonStudent
{
publicstaticvoidmain(String[] args) {
CollegeStudentobj1=newCollegeStudent("Mradul","GLA",2,"CS");
Teacherobj2=newTeacher("Neeraj",200000,"OOP");
obj1.display();
obj2.display();
}
}