Deck 12: Father Was a Rectangle: Inheritance and Object-Oriented Design

ملء الشاشة (f)
exit full mode
سؤال
The ____ relationship describes two objects where one object is a more specific instance of the other.

A) OF-A
B) HAS-A
C) IS-A
D) BELONGS-TO
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The ______ relationship describes two objects where one object uses another object.

A) OF-A
B) HAS-A
C) IS-A
D) BELONGS-TO
سؤال
In a hierarchy diagram, the most ____ object is at the top.

A) general
B) specific
C) complicated
D) simple
سؤال
In inheritance, the more general class is called the ____ class.

A) child
B) superclass
C) model
D) subclass
سؤال
When two classes are connected by an IS-A link, what do we call a class that inherits from a higher class in the inheritance hierarchy?

A) Subclass
B) Method
C) Instance variable
D) Superclass
سؤال
In an expanded object hierarchy for shapes, which of the following would be the most specific (or least general) class?

A) GeometricObject
B) Shape
C) Ellipse
D) Square
سؤال
Case Study 1:
1. myCanvas = Canvas (800, 600)
2. myLine = Line(Point (-100, -100), Point (100, 100))
3. myCanvas.draw(myLine)
-Refer to the session in the accompanying Case Study 1. What can be inferred about the Canvas class?

A) It will have a draw method.
B) It will be constructed with two Points.
C) It does not have a constructor.
D) It will have three instance variables.
سؤال
Case Study 1:
1. myCanvas = Canvas (800, 600)
2. myLine = Line(Point (-100, -100), Point (100, 100))
3. myCanvas.draw(myLine)
-Refer to the session in the accompanying Case Study 1. What can be inferred about the Point class?

A) It has a method draw.
B) It is required to create a Canvas.
C) It has at least two instance variables.
D) It is a subclass.
سؤال
The ____ method of the screen is used to define the width and height.

A) __init__
B) setup
C) move
D) setWidth
سؤال
What is the name of the property that allows Python to call the right method of an object depending on the type of object referenced by a superclass?

A) Polymorphism
B) Inheritance
C) Abstraction
D) Mutation
سؤال
In the object hierarchy presented in the text, GeometricObject is a(n) ____ class.

A) sub
B) specific
C) abstract
D) parameter
سؤال
How do you call the constructor of a superclass within a subclass?

A) __init()__
B) super().__init__()
C) super()
D) parent().init()
سؤال
How do you designate that B is a parent class of A?

A) class A extends B
B) class A[B]
C) class A(B)
D) class A of B:
سؤال
Case Study 2:
1. >>> myLine
2. &It;draw.Line object at 0x106f6b0>
3. >>> myCanvas
4. &It;draw.Canvas instance at 0x1070328>
5. >>> isinstance(myLine, Line)
6. ??????
-Refer to the session in the accompanying Case Study 2. What is output on line 6?

A) True
B) False
C) Line
D) myLine
سؤال
What variable holds the name of the parent of a class?

A) __parent__
B) __self___
C) __super__
D) __bases__
سؤال
When designing a project, it is a good idea to begin by making a list of the different kinds of objects involved and the relationships between those objects.
سؤال
The class where the IS-A link originates is called the superclass.
سؤال
It is good programming practice to write all the code for a large program at once and then to test it.
سؤال
The constructor method is always named __init__.
سؤال
The __dict__ variable is a dictionary that keeps track of the methods defined for the class.
سؤال
Match each definition with its term.
-A more general class.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
سؤال
Match each definition with its term.
-Provides us with one place to define instance variables and methods used by subclasses.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
سؤال
Match each definition with its term.
-A more specific class.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
سؤال
Match each definition with its term.
-The class from which all classes inherit.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
سؤال
What is the difference between an IS-A relationship and a HAS-A relationship?
سؤال
What is inheritance? As an example, explain how Shape and a Rectangle are related.
سؤال
Explain the benefits of using inheritance when creating a program that uses a variety of shapes with common characteristics.
سؤال
Explain how the Canvas draw method presented in your text makes use of the _draw method in GeometricObject.
سؤال
How does a Python object reference the class of which it is an instance?
سؤال
Explain how Python evaluates the expression myLine.getWidth().
سؤال
Describe the visibleObject instance variable that was added to the Canvas class presented in your text. How does this variable help improve drawing?
سؤال
Describe the drawAll method of the Canvas class presented in your text.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/32
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 12: Father Was a Rectangle: Inheritance and Object-Oriented Design
1
The ____ relationship describes two objects where one object is a more specific instance of the other.

A) OF-A
B) HAS-A
C) IS-A
D) BELONGS-TO
C
2
The ______ relationship describes two objects where one object uses another object.

A) OF-A
B) HAS-A
C) IS-A
D) BELONGS-TO
B
3
In a hierarchy diagram, the most ____ object is at the top.

A) general
B) specific
C) complicated
D) simple
A
4
In inheritance, the more general class is called the ____ class.

A) child
B) superclass
C) model
D) subclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
5
When two classes are connected by an IS-A link, what do we call a class that inherits from a higher class in the inheritance hierarchy?

A) Subclass
B) Method
C) Instance variable
D) Superclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
6
In an expanded object hierarchy for shapes, which of the following would be the most specific (or least general) class?

A) GeometricObject
B) Shape
C) Ellipse
D) Square
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
7
Case Study 1:
1. myCanvas = Canvas (800, 600)
2. myLine = Line(Point (-100, -100), Point (100, 100))
3. myCanvas.draw(myLine)
-Refer to the session in the accompanying Case Study 1. What can be inferred about the Canvas class?

A) It will have a draw method.
B) It will be constructed with two Points.
C) It does not have a constructor.
D) It will have three instance variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
8
Case Study 1:
1. myCanvas = Canvas (800, 600)
2. myLine = Line(Point (-100, -100), Point (100, 100))
3. myCanvas.draw(myLine)
-Refer to the session in the accompanying Case Study 1. What can be inferred about the Point class?

A) It has a method draw.
B) It is required to create a Canvas.
C) It has at least two instance variables.
D) It is a subclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
9
The ____ method of the screen is used to define the width and height.

A) __init__
B) setup
C) move
D) setWidth
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
10
What is the name of the property that allows Python to call the right method of an object depending on the type of object referenced by a superclass?

A) Polymorphism
B) Inheritance
C) Abstraction
D) Mutation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
11
In the object hierarchy presented in the text, GeometricObject is a(n) ____ class.

A) sub
B) specific
C) abstract
D) parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
12
How do you call the constructor of a superclass within a subclass?

A) __init()__
B) super().__init__()
C) super()
D) parent().init()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
13
How do you designate that B is a parent class of A?

A) class A extends B
B) class A[B]
C) class A(B)
D) class A of B:
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
14
Case Study 2:
1. >>> myLine
2. &It;draw.Line object at 0x106f6b0>
3. >>> myCanvas
4. &It;draw.Canvas instance at 0x1070328>
5. >>> isinstance(myLine, Line)
6. ??????
-Refer to the session in the accompanying Case Study 2. What is output on line 6?

A) True
B) False
C) Line
D) myLine
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
15
What variable holds the name of the parent of a class?

A) __parent__
B) __self___
C) __super__
D) __bases__
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
16
When designing a project, it is a good idea to begin by making a list of the different kinds of objects involved and the relationships between those objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
17
The class where the IS-A link originates is called the superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
18
It is good programming practice to write all the code for a large program at once and then to test it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
19
The constructor method is always named __init__.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
20
The __dict__ variable is a dictionary that keeps track of the methods defined for the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
21
Match each definition with its term.
-A more general class.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
22
Match each definition with its term.
-Provides us with one place to define instance variables and methods used by subclasses.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
23
Match each definition with its term.
-A more specific class.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
24
Match each definition with its term.
-The class from which all classes inherit.

A) Superclass
B) Abstract class
C) Subclass
D) The object class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the difference between an IS-A relationship and a HAS-A relationship?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is inheritance? As an example, explain how Shape and a Rectangle are related.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
27
Explain the benefits of using inheritance when creating a program that uses a variety of shapes with common characteristics.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
28
Explain how the Canvas draw method presented in your text makes use of the _draw method in GeometricObject.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
29
How does a Python object reference the class of which it is an instance?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
30
Explain how Python evaluates the expression myLine.getWidth().
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
31
Describe the visibleObject instance variable that was added to the Canvas class presented in your text. How does this variable help improve drawing?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
32
Describe the drawAll method of the Canvas class presented in your text.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.