Encapsulation is the more appropriate concept
Encapsulation is the more appropriate concept because the main design priority of the online exam system is to keep all exam-related data and operations together in a single organized unit.
In the scenario, the Exam class contains data such as exam ID, subject, total marks, and student responses, while also providing functions like submitAnswer() and calculateScore(). This shows that both the data and the related operations are combined within one class, which is the core idea of encapsulation.
Encapsulation is efficient for this requirement because it creates a modular and well-structured architecture. All exam functionalities are managed in one place, making the system easier to maintain, update, and expand in the future. For example, if the university later introduces new grading policies, negative marking, or different exam patterns, changes can be made inside the Exam class without affecting other parts of the system. This improves flexibility, reusability, and maintainability of the software.
Although the scenario also mentions that internal scoring logic is hidden from students and responses are securely validated, which relates to Information Hiding, this is described as a secondary security measure rather than the main design objective. The primary focus of the system is on organizing related data and behavior into a single unit for better software design, which directly represents Encapsulation.
Therefore, Encapsulation is the most suitable concept for this scenario, while Information Hiding acts as a supporting feature within the encapsulated design.
