educative.io

Educative

Why is there need of 2 different classes?

Why is there need of 2 different classes?
Can’t we print the values in the same first declared class?
Also what return sum does?? When the print func is dond in 2nd class

  1. Yes you can also do it with only one class.
  2. return sum: It returns the value to the place where the function was called. If you don’t return the sum to the print function, then it won’t print anything even if the sumsquare() is called inside it.