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?
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 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started