-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (24 loc) · 1.13 KB
/
Main.java
File metadata and controls
32 lines (24 loc) · 1.13 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
// A class that contains the main method to test the code sample
public class Main {
public static void main(String[] args){
// Create some student objects
Student s1 = new Student("Charlie", 1001);
Student s2 = new Student("David", 1002);
// Create some teacher objects
Teacher t1 = new Teacher("Eve", "Math");
Teacher t2 = new Teacher("Frank", "English");
// Create an array of students for each course
Student[] mathStudents = {s1, s2};
Student[] englishStudents = {s1};
// Create some person objects
Person p1 = new Student("Alice", 10);
Person p2 = new Teacher("Bob", "Science");
// Print some information about the objects
System.out.println("Person p1's name is " + p1.getName());
System.out.println("Person p2's name is " + p2.getName());
System.out.println("Student s1's name is " + s1.getName());
System.out.println("Student s1's id is " + s1.getId());
System.out.println("Teacher t1's name is " + t1.getName());
System.out.println("Teacher t1's subject is " + t1.getSubject());
}
}