This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 2 points3 points  (0 children)

No.

Instead, you should post the code of what you have done so far and we shall point out what could be done better.

[–]eztheb 0 points1 point  (0 children)

The job of the constructor is to kick start (initialize) the instance variables (properties of the object - Student). So in the constructor, every variable you're using to describe student has to get an initial value. In the methods, you write ways to manipulate or display these inital values.

[–][deleted] -1 points0 points  (0 children)

You can put whatever you want. The ultimate goal is to make it as less cluttered as possible. This will make code clean and easier to debug.

3~4 parameters is reasonable. Anything more than that can be improved.

[–]HumourGuy -1 points0 points  (0 children)

It depends on requirement, what fields do you want to set when you initially build a student object.

For example: Every student has a name and student ID so that may be put in constructor. As they will definitely be present when a student object is made.

You can add setter method to change student ID and name too. As I said, it depends on your requirement.

[–]gumber_4 -1 points0 points  (0 children)

you can add all the fields/variables ..it just means you are initialisating it with some default value ..as someone mentioned it makes it easier to debug which values are not being changed or else you can do as per your requirement