Project Requirements (The Blueprint)

To make this a true “OOP” project, we will implement the following:

  1. Encapsulation: Private fields for student data with public Getters and Setters.

  2. Inheritance: A base class Person and a child class Student.

  3. Polymorphism: Overriding a method to display specific info.

  4. Abstraction: Using an interface or abstract class to define “System Operations.”

  5. Constructors: To initialize student objects quickly.


💻 Complete Code Implementation

1. The Interface (Abstraction)

This defines what our system must do.

Java

 
interface ManagementActions {
    void displayDetails(); // Contract: Every person in the system must show details
}

2. The Parent Class (Inheritance)

Java

 
abstract class Person implements ManagementActions {
    private String name; // Encapsulation: Private data

    public Person(String name) { // Constructor
        this.name = name;
    }

    public String getName() { return name; } // Getter
    public void setName(String name) { this.name = name; } // Setter
}

3. The Child Class (Inheritance & Polymorphism)

Java

 
class Student extends Person {
    private int rollNumber;
    private double gpa;

    // Parameterized Constructor
    public Student(String name, int rollNumber, double gpa) {
        super(name); // Calling Parent constructor
        this.rollNumber = rollNumber;
        this.gpa = gpa;
    }

    // Method Overriding (Polymorphism)
    @Override
    public void displayDetails() {
        System.out.println("Name: " + getName());
        System.out.println("Roll Number: " + rollNumber);
        System.out.println("GPA: " + gpa);
        System.out.println("-------------------------");
    }
}

4. The Main Execution (Logic & Input/Output)

Java

 
import java.util.Scanner;

public class StudentManagementSystem {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        System.out.println("=== University Student Portal ===");
        
        // Input Section (Using Scanner)
        System.out.print("Enter Student Name: ");
        String n = sc.nextLine();
        
        System.out.print("Enter Roll Number: ");
        int r = sc.nextInt();
        
        System.out.print("Enter GPA: ");
        double g = sc.nextDouble();

        // Creating the Object (Using Constructor)
        Student s1 = new Student(n, r, g);

        // Display Output
        System.out.println("\n--- Student Successfully Registered ---");
        s1.displayDetails();
        
        sc.close();
    }
}

📝 Student Viva/Project Defense Questions

If you present this to your university teacher, they might ask:

  1. “Where is Abstraction here?” * Answer: In the ManagementActions interface. It defines what needs to be done without saying how.

  2. “Why use super(name)?” * Answer: To pass the name to the Parent class (Person) constructor, as the Parent class is responsible for handling the name field.

  3. “How is this secure?”

    • Answer: Because the variables are private. No one can change the name or GPA directly; they must use the methods provided.


🎓 Final Conclusion of the Course

You have successfully moved from basic Input/Output to building a Complete OOP System.

  • Lesson 1-3: You learned the basics.

  • Section 3-4: You learned how to think in “Objects.”

  • Section 5: You mastered the Four Pillars that professional engineers use.