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 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 declare two fields:

  • string _name
  • string _rollNumber

and implement properties for these fields:

  • Name
  • RollNumber

Implement this class according to the rules of encapsulation.

There is no need to add constructor in this class. The fields should be set using the properties defined in the class.

Get hands-on with 1200+ tech skills courses.