-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPersonStudent.java
More file actions
54 lines (51 loc) · 1.16 KB
/
PersonStudent.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
public class Person {
String name;
Person(String name)
{
this.name=name;
}
}
class Student extends Person
{
String CollegeName;
public Student(String name, String CollegeName) {
super(name);
this.CollegeName = CollegeName;
}
}
class Teacher extends Person
{
int salary;
String subject;
public Teacher(String name,int salary, String subject) {
super(name);
this.salary = salary;
this.subject = subject;
}
void display()
{
System.out.println(name+" "+salary+" "+subject);
}
}
class CollegeStudent extends Student
{
int year;String major;
public CollegeStudent(String name, String collegeName, int year, String major) {
super(name, collegeName);
this.year = year;
this.major = major;
}
void display()
{
System.out.println(name+" "+CollegeName+" "+year+" "+major);
}
}
class PersonStudent
{
public static void main(String[] args) {
CollegeStudent obj1=new CollegeStudent("Mradul","GLA",2,"CS");
Teacher obj2=new Teacher("Neeraj",200000,"OOP");
obj1.display();
obj2.display();
}
}