School Management System

This program models a simple school management system.

Problem Statement

Write a Java program to model Teacher and Student classes with interaction.

Source Code

1 class Student {
2 String name;
3 Student(String n){ name=n; }
4 void learn(){ System.out.println(name+" is learning"); }
5 }
6 class Teacher {
7 String name;
8 Teacher(String n){ name=n; }
9 void teach(Student s){ System.out.println(name+" teaches "+s.name); }
10 }
11 public class SchoolManagement {
12 public static void main(String[] args) {
13 System.out.println("Eduinq School Management System");
14 Student s=new Student("Arun");
15 Teacher t=new Teacher("Rahul");
16 t.teach(s); s.learn();
17 }
18 }

Program Output

Eduinq School Management System
Rahul teaches Arun
Arun is learning

Explanation

Teacher and Student classes model real world school scenario. - Teacher interacts with Student through teach() method. - Student responds with learn() method. - This demonstrates object interaction and encapsulation in real world modeling. Conclusion: Shows how to model school management system using OOP.

Quick Links to Explore