-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
35 lines (34 loc) · 960 Bytes
/
Person.java
File metadata and controls
35 lines (34 loc) · 960 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
34
35
public class Person {
Teacher obj2 = new Teacher(50000.00, "Computer Science");
Student obj3 = new Student();
public void m1(){
System.out.println(obj2.salary);
System.out.println(obj2.subject);
}
public static void main(String[] args) {
Person obj = new Person();
obj.m1();
System.out.println(".........................................");
System.out.println(obj.obj3.obj1.year);
System.out.println(obj.obj3.obj1.major);
}
}
class Student extends Person{
CollegeStudent obj1 = new CollegeStudent(2, "Computer Science Engineering");
}
class Teacher extends Person{
double salary;
String subject;
Teacher(double sa, String s){
salary = sa;
subject = s;
}
}
class CollegeStudent extends Student{
int year;
String major;
CollegeStudent(int y, String m){
year = y;
major = m;
}
}