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

1 An instance variable refers to a data value that a is owned by an particular i

ID: 3670628 • Letter: 1

Question

1 An instance variable refers to a data value that

a is owned by an particular instance of a class and no other

b is shared in common and can be accessed by all instances of a

given class

2 The name used to refer the current instance of a class within the class

definition is

a this

b other

c self

3 The purpose of the __init__ method in a class definition is to

a build and return a string representation of the instance variables

b set the instance variables to initial values

4 A method definition

a can have zero or more parameter names

b always must have at least one parameter name, called self

5 The scope of an instance variable is

a the statements in the body of the method where it is introduced

b the entire class in which it is introduced

c the entire module where it is introduced

6 An object’s lifetime ends

a several hours after it is created

b when it can no longer be referenced anywhere in a program

c when its data storage is recycled by the garbage collector

7 A class variable is used for data that

a all instances of a class have in common

b each instance owns separately

8 Class B is a subclass of class A. The __init__ methods in both classes

expect no arguments. The call of class A’s __init__ method in class B is

a A.__init__()

b A.__init__(self)

9 The easiest way to save objects to permanent storage is to

a convert them to strings and save this text to a text file

b pickle them using the cPickle method save

10 A polymorphic method

a has a single header but different bodies in different classes

b creates harmony in a software system

Explanation / Answer

1.A

2.A

3.B

4.A

5.B

6.C

7.A

8.B

9.B

10.A

If any queries kindly get back to me