Question 11 pts A UML class diagram Flag this Question Question 21 pts Consider
ID: 3915654 • Letter: Q
Question
Question 11 pts
A UML class diagram
Flag this Question
Question 21 pts
Consider the following code:
class Multiplier:
def __init__(self):
self.num1 = 0
self.num2 = 0
def getProduct(self):
return self.num1 * self.num2
def main():
m = Multiplier()
m.num1 = 7
m.num2 = 3
print(m.num1, "X", m.num2, "=", m.getProduct())
if __name__ == "__main__":
main()
What is (are) the methods of the class?
Flag this Question
Question 31 pts
Consider the following code:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = width
def getPerimeter(self):
perimeter = self.height * 2 + self.width * 2
return perimeter
def getArea(self):
area = self.height * self.width
return area
def getStr(self):
return str(self.height) + " by " + str(self.width)
How many public attributes does this class define?
Flag this Question
Question 41 pts
Consider the following code:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = width
def getPerimeter(self):
perimeter = self.height * 2 + self.width * 2
return perimeter
def getArea(self):
area = self.height * self.width
return area
def getStr(self):
return str(self.height) + " by " + str(self.width)
How many public methods does this class define?
Flag this Question
Question 51 pts
Consider the following code:
class Die:
def __init__(self):
self.__value = 1
def getValue(self):
return self.__value
def roll(self):
self.__value = random.randrange(1, 7)
Given a Die object named die, which of the following will print the value of the __value attribute to the console?
Flag this Question
Question 61 pts
Consider the following code:
class Multiplier:
def __init__(self):
self.num1 = 0
self.num2 = 0
def getProduct(self):
return self.num1 * self.num2
def main():
m = Multiplier()
m.num1 = 7
m.num2 = 3
print(m.num1, "X", m.num2, "=", m.getProduct())
if __name__ == "__main__":
main()
What is (are) the attributes of the class?
Flag this Question
Question 71 pts
Given a class named Customer, which of the following creates a Customer object and assigns it to the variable named cust1:
Flag this Question
Question 81 pts
Given a variable named p that refers to a Product object, which of the following statements accesses the price attribute of the Product object?
Flag this Question
Question 91 pts
In a method, the first parameter, which is usually named self, refers to the current
Flag this Question
Question 101 pts
The methods contained in an object that has been created from a class is its __________.
describes the functions of one or more modulesExplanation / Answer
Answer 11:
A UML class diagram
describes the attributes and methods of one or more classes
Explanation:
A UML class diagram is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects.;
Answer 21:
The methods of the class are
getProduct()
__init__()
Answer 31:
Public attributes does this class define?
4
these are height, width, perimeter and area
Explanation:
All member variables and methods are public by default in Python. So when you want to make your member public, you just do nothing.
Protected member variables and methods are by convention - by prefixing the name of your member with a single underscore.
Private member variables and methods are by convention - by prefixed with at least two underscores and suffixed with at most one underscore into _<className><memberName>.
Answer 41:
Public methods does this class define?
3
These are a) getPerimeter(self) b) getArea(self) c) getStr(self)
Explanation:
All member variables and methods are public by default in Python. So when you want to make your member public, you just do nothing.
Protected member variables and methods are by convention - by prefixing the name of your member with a single underscore.
Private member variables and methods are by convention - by prefixed with at least two underscores and suffixed with at most one underscore into _<className><memberName>.
Answer 51:
Given a Die object named die, which of the following will print the value of the __value attribute to the console?
print(die.getValue())
Answer 61:
What is (are) the attributes of the class?
num1, num2
Answer 71:
Given a class named Customer, which of the following creates a Customer object and assigns it to the variable named cust1:
cust1 = Customer()
Answer 81:
Given a variable named p that refers to a Product object, which of the following statements accesses the price attribute of the Product object??
p.price
Answer 91:
In a method, the first parameter, which is usually named self, refers to the current?
object
Please give thumbsup, if you like it. Thanks.
.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.