Challenge: The Single Responsibility Principle

Test your knowledge of using the Single Responsibility Principle to improve your code.

We'll cover the following


Refactor the given Student class, which currently has too many responsibilities. Use the Single Responsibility Principle (SRP) so that the class handles only a single responsibility.


Our code currently consists of three files,,, and We have two classes within Student and SemesterResult.

We create instances of Student and test the classes in by using the data provided in

The class Student currently is responsible for multiple responsibilities, and thus violates the SRP. Identify the different responsibilities undertaken by the class and refactor the code so that it adheres to the SRP. Divide the responsibilities into separate classes if needed.

Get hands-on with 1200+ tech skills courses.