Computer Science, asked by rinakharde1996, 4 months ago

If a field is declared as a var then Scala generates
field.
methods for that​

Answers

Answered by kk11871970
0

Answer:

join girl for fun I'd -657 729 4778

password-kaus

Answered by roopa2000
0

Answer:

If a field is declared as var, Scala creates both getter and setter methods for that field. If the field is a val, Scala only spawns a getter method for it.

Explanation:

Here's the abridged version here:

  • If a field is declared as var, Scala generates both getter and setter methods for that field.
  • If the field is a val, Scala only generates a getter method for it.
  • If a field does not have a var or val modifier, Scala becomes conservative, and does not generate a getter or setter method for the field.
  • Additionally, the var and val fields can be modified with the private keyword, which prevents getters and setters from being generated.
Similar questions