Question: PYTHON 12. Which of the following is NOT true about instance methods for a class? The object on which a method is applied is automatically
PYTHON
12. Which of the following is NOT true about instance methods for a class?
The object on which a method is applied is automatically passed to the self parameter variable of the method
In a method, you access instance variables through the self parameter variable
A class variable belongs to the class, not to any instance of the class
The accessor and mutator methods are automatically called when an object is created
13. Consider the following class, Which method is an accessor?
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
14. How do you access instance variables in a method?
Using the constructor
Using a setter variable
Using a default value
Using the self reference
15. Use ____ to store an object to a file.
objectName = pickle_load(file_variable)
pickle_dump(objectName, file_Variable)
17. How many constructors can be defined for each class?
Constructors are not used in Python
Only one may be defined
At least one, but as many as needed
At least one, but no more than five
What is the purpose of the self parameter?
| Enables changes in the implementation without affecting users of a class |
| To create variables with public visibility |
| Store the data for all objects created by the same class |
| Refers to the object on which the method was invoked |
True or False: "The pickle module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python object structure."
True or False: "Before invoking a method on an object, the object must have first been instantiated."
True or False: As a class is instantiatedits its constructor executes.
True or False: A constructor is often used to initialize class variables
Python's ____ function is used to determine whether or not two objects are of the same type.
is
type
in
eq
"A(n) ____ class includes data and methods common to its subclasses, but is never instantiated."
polymorphic
abstract
encapsulated
anonynous
Assume a class exists named Fruit. Which of the follow statements constructs an object of the Fruit class?
def Fruit()
class Fruit()
x = Fruit()
x = Fruit.create()
What method name is used for a constructor?
__begin__
__construct__
__create__
__init__
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
