Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Homework 4 Could you please help me answer these questions? 11.) Most classes include a special method named ____, which is the class's constructor.

PYTHON Homework 4 Could you please help me answer these questions?

11.) Most classes include a special method named ____, which is the class's constructor.

a.) _self

b.) __self__

c.) _init

d.) __init__

12.) Methods that allow a user to modify an object's state are called ____.

a.) mutators

b.) modifiers

c.) writers

d.) output methods

13.) Which of the following is NOT true about instance methods for a class?

a.) The object on which a method is applied is automatically passed to the self parameter variable of the method

b.) In a method, you access instance variables through the self parameter variable

c.) A class variable belongs to the class, not to any instance of the class

d.) The accessor and mutator methods are automatically called when an object is created

14.) 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

a.) getValue

b.) click

c.) unClick

d.) reset

15.) How do you access instance variables in a method?

a.) Using the constructor

b.) Using a setter variable

c.) Using a default value

d.) Using the self reference

16.) use ____ to store an object to a file.

a.) objectName = pickle.load(file_variable)

b.) pickle.dump(objectName, file_Variable)

17.) What is the name of the instance variable in the following code segment?

class Fruit :

def getColor(self) :

return self._color

a.) _color

b.) Fruit

c.) getColor

d.) self

18.) How many constructors can be defined for each class?

a.) Constructors are not used in Python

b.) Only one may be defined

c.) At least one, but as many as needed

d.) At least one, but no more than five

19.) What is the purpose of the self parameter?

a.) Enables changes in the implementation without affecting users of a class

b.) To create variables with public visibility

c.) Store the data for all objects created by the same class

d.) Refers to the object on which the method was invoked

20.) What is the definition of a class?

a.) A class is exactly the same thing as a function

b.) A class decomposes tasks into functions

c.) A class describes a set of objects with the different behaviors

d.) A class describes a set of objects with the same behavior

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago