educative.io

Calling calcTotal() method withour parameters

Hello,

I am comparing the solution to my work.

In the solution of this Calculate the Student’s Total marks, how does the instance (student) call the calcTotal() withour parameters?

Please can you shed more light

Kind regards,

Tinzs

Hi @Tinzs
Thanks for reaching out to us. In the lesson, when the student instance is created, the parameterized constructor is called and the values of name, mark1, and mark2 are set. Student student = new Student("Jack", 60, 70);
When we call the function System.out.println(student.calcTotal());, we do not set parameters again because they were already set at the time of the instance created.

Hope it will help, Happy Learning :slight_smile: