use python to solve these Qs: Which of the following is considered by the text t
ID: 3713029 • Letter: U
Question
use python to solve these Qs:
Which of the following is considered by the text to be the most important consideration when designing a class?
Question 1 options:
a) Which of the following is considered by the text to be the most important consideration when designing a class?
b) Each class should represent a single concept or object from the problem domain.
c) Each class should represent no more than three specific concepts.
d) Each class should represent multiple concepts only if they are closely related.
Save
Question 2 (2 points)
2) Which of the following is NOT a difference between methods and functions?
Question 2 options:
a) A method is defined as part of a class definition
b) A function is defined as part of a class definition
c) The first parameter variable of a method is called self
d) A method can access the instance variables of an object
Save
Question 3 (2 points)
3) Suppose you have a class ShoppingList, with instance variables _quantity, _cost, and _itemName, how can you access these variables in your program?
Question 3 options:
a) Directly access the variables
b) Use a method provided by the ShoppingList class
c) It is not possible to access the variables
d) Use the self parameter
Save
4) Assume a class exists named Fruit. Which of the follow statements constructs an object of the Fruit class?
Question 4 options:
a) def Fruit() :
b) class Fruit() :
c) x = Fruit()
d) x = Fruit.create()
Save
Question 5 (2 points)
5) What is the name of the method in the following code segment?
class Fruit :
def getColor(self) :
return self._color
Question 5 options:
a) _color
b) Fruit
c) getColor
d) self
a) Which of the following is considered by the text to be the most important consideration when designing a class?
b) Each class should represent a single concept or object from the problem domain.
c) Each class should represent no more than three specific concepts.
d) Each class should represent multiple concepts only if they are closely related.
Explanation / Answer
Q1-(d) Each class should represent a single concept or object from the problem domain because A class is a template for creating
objects. It is a grouping of object-oriented constructs.
Q2. b) A function is defined as part of a class definition is a wrong choice because a method is a part of class definition instead of
class.
Q3 b) Use a method provided by the ShoppingList class because we can access private variables using methods.
Q4.c) x = Fruit() Because this is the way to create a object in Python
Q5.c) getColor getColor is the method name
(Please rate the answers)
Thank you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.