Question
Consider the following class: class Counter : def getValue(self) : return self._value def click(self) : self._value = self._value + 1 def unClick(self) : self._value =
Consider the following class: class Counter : def getValue(self) : return self._value def click(self) : self._value = self._value + 1 def unClick(self) : self._value = self._value - 1 def reset(self) : self._value = 0
Which method(s) are mutators?
Question 6 options:
a) Only reset | |
b) Only click and unClick | |
c) Only click, unClick and reset | |
d) All four methods are mutators |
Save
Question 7 (2 points)
7) Which of the following method headers represent a constructor?
Question 7 options:
a) def init(self) : | |
b) def __init__(self) : | |
c) def _init(self) : | |
d) def init() : |
Save
Question 8 (2 points)
8) How do you access instance variables in a method?
Question 8 options:
a) Using the constructor | |
b) Using the public interface | |
c) Using a default value | |
d) Using the self reference |
Save
Question 9 (2 points)
9) Consider the following code segment: def mutate(self, newType) : self._type = newType self._mutations = self._mutations + 1
What is the name of the local variable in it:
Question 9 options:
a) mutate | |
b) _mutations | |
c) newType | |
d) _type |
Save
Question 10 (2 points)
10) Which method below would be considered an accessor method?
Question 10 options:
a) getCount() | |
b) addItem() | |
c) clearCount() | |
d) updateItem() |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started