Pt. 2 - EASY PYTHON Multi Choice questions 1a) What is wrong with the following constructor? def __init__(): self._weight = 0.0 self._color = None The
Pt. 2 - EASY PYTHON Multi Choice questions
1a) What is wrong with the following constructor?
def __init__(): self._weight = 0.0 self._color = "None"
| The constructor must have a different name |
| The constructor must take the self parameter |
| The constructor must initialize _color before _weight |
1b) A constructor
| must use assignment statements to initialize class data |
| may use assignment statements to initialize class data. |
| must use mutators to initialize class data. |
| may use mutators to initialize class data. |
1c) Instance variables are__________
| member variables whose values are shared by all object instances of the class. |
| member variables whose values are unique to each object of the class. |
| types of local variables that get their values from the main function. |
1d) The method is automatically called when an object is created.
1e) Which method below would be considered a mutator method?
1f) Which method below would be considered an accessor method?
1g) Before invoking a method on an object, what must be done first?
| Initialize all instance variables |
| Invoke the accessor and mutator methods |
| Create a public interface |
1h) A method that queries an object for some information without changing it is known as a(n):
| Mutator 1i) Assume a class exists named Fruit. Which of the follow statements constructs an object of the Fruit class? 1j What is the name of the method in the following code segment? class Fruit : def getColor(self): return self._color |