That code shows that fields not marked
private are accessible from outwith their class. The field
a can be changed from elsewhere, so it shows lack of encapsulation.
You have been told correctly what the setB() method does, but it hasn't been explained. Because you have a field and a parameter both with the same name, the parameter takes precedence. To make sure you are referring to the field rather than the parameter, you call the field
this.b. As you know,
this is a keyword meaning the current object.
And (again) welcome to the Ranch
