Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following class: class Counter : def getValue(self) : return self._

ID: 3713030 • Letter: C

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 = 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()

a) Only reset

b) Only click and unClick

c) Only click, unClick and reset

d) All four methods are mutators

Explanation / Answer

6) c

Only click, unClick and reset

7) b

def __init__(self) :

8) d

Using the self reference

9) b

_mutations

10) a

getCount()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote