Course Hero Logo

Which name would be best for a private instance

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 13 - 16 out of 29 pages.

Which name would be best for a private instance variable?typemcSection9.4 Designing the Data Representationidtestbank-py-1-ch09-39
40.What is the purpose of a constructor?Title
What is the purpose of a constructor?41.When is a constructor invoked?
42.Which of the following method headers represent a constructor?1. def init(self) :2. def __init__(self) :3. def _init(self) :4. def init() :
TitleWhich of the following method headers represent a constructor?43.Consider the classEmployee:
class Employee :def __init__(self, firstName, lastName, employeeId) :self._name = lastName + "," + firstNameself._employeeId = employeeId. . .If an object is contructed as:sam = Employee("Sam", "Fisher", 54321)What is the contents of the instance variable _name?
TitleGiven the constructor for the class Employee, what is the contents of one of the instancevariables?
44.Which of the following method headers represent a constructor for anEmployeeclass?1. def Employee(self) :2. def __init()__ :3. def __Employee__(self) :4. def __init__(self) :
TitleWhich of the following method headers represent a constructor?
mcSection9.5 Constructorsidtestbank-py-1-ch09-4445.How many constructors can be defined for each class?
How many constructors can be defined for each class?
46.Consider the following code segment:class PhoneNumber :def __init__(self, lName, phone = "215-555-1212") :self._name = lNameself._phone = phonedef getName(self):return self._namedef getPhone(self):return self._phoneJones = PhoneNumber("Jones")print(Jones.getName(), Jones.getPhone())What will be printed when it executes?

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 29 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
Object Oriented Programming, ShoppingList class

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture