Parameterized Constructor

You are given an integer a.

Create a class Student with the following field:

  • age (integer)

Implement a parameterized constructor that assigns the value of a to age.

Create an object of class Student using the parameterized constructor and return the object.

Note:

  • The class name must be exactly Student
  • The field name must be exactly age and it should be public

Example 1:

Input: a = 10

Output: 10

Example 2:

Input: a = 50

Output: 50

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= a <= 100
0
class Solution {
public:
Student createStudent(int a) {
//your code goes here
}
};
Test Case

Input:

A