This project is for a student exam portal. Students need to register to the exam system and then log in using their Student_id and password. To start an exam, they need to select a course name, and then the exam will begin. There are 10 'Multiple Choice Question (MCQ)', each with 4 options (A, B, C, D). Students must select the correct answer and proceed to the next question. After completing all 10 questions, students click the 'Finish' button to end the exam. Their final score is then displayed and saved to the database. There will also be a 'Teacher' account. Teachers can view, add, delete, and update questions. They can also view the final summary report of the exam by course.

// Java code implementation

// Student class public class Student { private int studentId; private String password; private String name;

public Student(int studentId, String password, String name) {
    this.studentId = studentId;
    this.password = password;
    this.name = name;
}

// getter and setter methods omitted

// Registration method
public void register() {
    // Save student information to the database
    // ...
}

// Login method
public boolean login(int studentId, String password) {
    // Check if student information exists in the database
    // If it exists, return true; otherwise, return false
    // ...
}

// Course selection method
public void selectCourse(String courseName) {
    // Get question information based on course name
    // ...
}

// Answer question method
public void answerQuestion(int questionId, String answer) {
    // Save the answer to the database
    // ...
}

// Click finish button method
public void finishExam() {
    // Calculate the score and save it to the database
    // ...
}

}

// Teacher class public class Teacher { private String username; private String password;

public Teacher(String username, String password) {
    this.username = username;
    this.password = password;
}

// getter and setter methods omitted

// View question method
public void viewQuestions(String courseName) {
    // Query question information based on course name
    // ...
}

// Add question method
public void addQuestion(String courseName, String question, String optionA, String optionB, String optionC, String optionD, String answer) {
    // Save question information to the database
    // ...
}

// Delete question method
public void deleteQuestion(int questionId) {
    // Delete question information from the database based on question ID
    // ...
}

// Update question method
public void updateQuestion(int questionId, String question, String optionA, String optionB, String optionC, String optionD, String answer) {
    // Update question information based on question ID
    // ...
}

// View summary report method
public void viewSummaryReport(String courseName) {
    // Query the summary report of the exam based on course name
    // ...
}

}

// MySQL database operation class public class MySQLUtil { private static final String URL = "jdbc:mysql://localhost:3306/exam_portal"; private static final String USERNAME = "root"; private static final String PASSWORD = "123456";

// Register driver
static {
    try {
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

// Get database connection
public static Connection getConnection() throws SQLException {
    return DriverManager.getConnection(URL, USERNAME, PASSWORD);
}

// Close database connection
public static void close(Connection conn, Statement stmt, ResultSet rs) {
    try {
        if (rs != null) {
            rs.close();
        }
        if (stmt != null) {
            stmt.close();
        }
        if (conn != null) {
            conn.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

// Execute SQL statement
public static void execute(String sql) {
    Connection conn = null;
    Statement stmt = null;
    
    try {
        conn = getConnection();
        stmt = conn.createStatement();
        stmt.execute(sql);
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        close(conn, stmt, null);
    }
}

// Execute query operation
public static ResultSet query(String sql) {
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    
    try {
        conn = getConnection();
        stmt = conn.createStatement();
        rs = stmt.executeQuery(sql);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    
    return rs;
}

}

Java and MySQL Based Student Exam Portal: Design and Implementation