1. Accessor methods are used for initializing and accessing the value of ______________.
2. Getter and setter methods allow us to get and set instance variables from the ___________.
3. An accessor method is useful for efficiency and speed but it does not make the program more readable and understandable.
4. One of the ways we can enforce data ______________ is through the use of accessors and mutators.
5. The role of accessors and mutators are to return and set the values of an object's __________.
6. An alternative to using an accessor method is to just change the private fields of the class definition to be public and achieve the same results.
7. The name of an accessor method starts with the word _____.
8. What is missing from the following code? (accessor method)
9. Which statement is true of the following list?
10.
We use getter and setter methods for validation, to hide internal representation, expansion, and ______.
11. Getter methods usually return a number of different variables, including ones from other functions that we may not be trying to get.
12. When creating getter methods there is a common convention you should follow. Use this format: get[Variable Name] for the name.
13. Getter (accessor) methods are also known as modifier methods
14. Here is an example of an accessor method called __________ for the Student class which also demonstrates how to call ________using a Student object:
15. Accessor methods that return primitive types use "return by value" where a copy of the value is returned.
16. When the return expression is a reference to an object, a copy of that reference is returned, not a copy of the object.
17. Analyse the code below. The method getNumOfPeople does NOT work because the method should have at least one parameter.
18. Referring to the code above, the instance variable num should be returned instead of numOfPeople, which is local to the constructor. (then it will work!)
19. To get the code in question 17 to work, the getNumOfPeople method should be declared as public.
20. Consider the code below. Which of the following reasons explains why this code does not compile?