Challenge 2: Implement the Complete Student Class

Can you implement the Student class using the concepts of encapsulation? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first.

We'll cover the following

Problem Statement #

You are given a Student class in the editor. Your task is to add two fields:

  • String name
  • String rollNumber

and provide getter/setters for these fields:

  • getName
  • setName
  • getRollNumber
  • setRollNumber

Implement this class according to the rules of encapsulation.

Input #

Checking all fields and getters/setters

Output #

Expecting perfectly defined fields and getter/setters.

There is no need to add constructors in this class.

Get hands-on with 1200+ tech skills courses.