Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pt. 2 - EASY PYTHON Multi Choice questions 1a) What is wrong with the following constructor? def __init__(): self._weight = 0.0 self._color = None The

Pt. 2 - EASY PYTHON Multi Choice questions

1a) What is wrong with the following constructor?

def __init__(): self._weight = 0.0 self._color = "None" 

The constructor must have a different name

The constructor must take the self parameter

The constructor must initialize _color before _weight

1b) A constructor

must use assignment statements to initialize class data

may use assignment statements to initialize class data.

must use mutators to initialize class data.

may use mutators to initialize class data.

1c) Instance variables are__________

member variables whose values are shared by all object instances of the class.

member variables whose values are unique to each object of the class.

types of local variables that get their values from the main function.

1d) The method is automatically called when an object is created.

__init__ 
init 
__str__ 
__object__ 

1e) Which method below would be considered a mutator method?

getCount() 
addItem() 
getTotal() 
printItem() 

1f) Which method below would be considered an accessor method?

getCount() 
addItem() 
clearCount() 
updateItem() 

1g) Before invoking a method on an object, what must be done first?

Initialize all instance variables
Invoke the accessor and mutator methods
Create a public interface
Construct the object

1h) A method that queries an object for some information without changing it is known as a(n):

Accessor
Function
Interface

Mutator

1i) 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() 

1j What is the name of the method in the following code segment?

class Fruit : def getColor(self): return self._color 
_color 
Fruit 
getColor 
self 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions