For the first part the answer is scope:
scala> class Person(name: String, age: Int) {
| def say = "My name is " + name + ", age " + age
| }
scala> val x = new Person("Hitman", 40)
scala> x.name
<console>:10: error: value name is not a member of Person
x.name
If you prefix parameters with val
, var
they will be visible from outside of class, otherwise, they will be private, as you can see in code above.
And yes, you can change value of the var, just like usually.