Week 11 Flashcards

1
Q

New attributes and methods may be added to a subclass.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

One problem with using a UML diagram is that there is no way to indicate inheritance.

A

false lol the whole point of the diagram is to show inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When a class inherits another class, it is required to use all the data attributes and methods of the superclass.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Polymorphism works on any two class methods that have the same name.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A subclass may not override any method other than the __init__ method.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Each subclass has a method named __init__ that overrides the superclass’s __init__ method.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In a UML diagram depicting inheritance, you only need to write the name of the subclass.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

An “is a” relationship exists between a grasshopper and a bumblebee.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

An “is a” relationship exists between a wrench and a tool.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

__________ allows a new class to inherit members of the class it extends.
a. Encapsulation
b. Attributes
c. Methods
d. Inheritance

A

inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What gives a program the ability to call the correct method depending on the type of object that is used to call it?
a. Polymorphism
b. Inheritance
c. Encapsulation
d. Methods

A

a. Polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does a subclass inherit from a superclass?
a. instances and attributes
b. objects and methods
c. methods and instances
d. attributes and methods

A

attributes and methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In a UML diagram, what does the open arrowhead point to?
a. the superclass
b. the subclass
c. the object
d. a method

A

The superclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When there are several classes that have many common data attributes, it is better to write a(n) __________ to hold all the general data.
a. superclass
b. subclass
c. object
d. method

A

a. superclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In an inheritance relationship, what is a specialized class called?
a. a superclass
b. a subclass
c. an object
d. an instance

A

a subclass

17
Q

Base classes are also called
a. superclasses
b. derived classes
c. subclasses
d. class instances

A

a. superclasses

18
Q

What is the relationshop called in which one object is a specialized version of another object?
a. parent-child
b. node-to-node
c. is a
d. class-subclass

A

c. is a

19
Q

__________ has the ability to define a method in a subclass and then define a method with the same name in a superclass.
a. Inheritance
b. Encapsulation
c. Polymorphism
d. the ‘is a’ relationship

A

Polymorphism

20
Q

In the following line of code, what is the name of the subclass?
class Rose(Flower):
a. Rose
b. Flower
c. Rose(Flower)
d. None of these

A

rose

21
Q

In the following line of code, what is the name of the base class?
class Python(Course):
a. Python
b. Course
c. Python(Course)
d. None of these

A

course

22
Q

Given the following line of code, in a UML diagram, what would the open arrowhead point to?
class Celery(Vegetable):
a. Celery
b. Vegetable
c. class
d. Celery(Vegetable)

A

vegetable

23
Q

Of the two classes, Cherry and Flavor, which would most likely be the subclass?
a. Cherry
b. Flavor
c. either one
d. neither; these are inappropriate class or subclass names

A

Cherry

24
Q

Which method can you use to determine whether an object is an instance of a class?
a. isinstance
b. isclass
c. isobject
d. issubclass

A

isinstance

25
Q

Which of the following is the correct syntax for defining a class, table, which inherits from the furniture class?
a. class furniture[table]:
b. class table.furniture:
c. class furniture(table):
d. class table(furniture):

A

class table(furniture):

26
Q

Given the following beginning of a class definition for a superclass named clock, how many accessor and mutator methods will be needed to complete the class definition?
class clock:
def __init__(self, shape, color, price):
self._shape = shape
self.color = color
self.price = price
a. 1 mutator, 1 accessor
b. 3 mutator, 4 accessor
c. 3 mutator, 3 accessor
d. 4 mutator, 5 accessor

A

3 mutator, 3 accessor

27
Q

__________ allows subclasses to have methods with the same names as methods in their superclasses.

A

Polymorphism

28
Q

The __________ function determines whether or not an object is an instance of a specific class or an instance of a subclass of that class.

A

isinstance

29
Q

A subclass is also called a(n) __________ class.

A

derived class

30
Q

A superclass is also called a(n) __________ class.

A

base

31
Q

When a subclass method has the same name as a superclass method, the subclass method __________ the superclass method.

A

overrides

32
Q

In an inheritance relationship, the extended class is called the __________.

A

Superclass

33
Q

New attributes and methods may be added to a subclass which makes it a(n) __________ version of the superclass.

A

True

34
Q

In an inheritance relationship, a minivan can be thought of as a(n) ___________ of the vehicles class.

A

Subclass, derived class

35
Q

The term ___________ refers to an object’s ability to take different forms.

A

Polymorphism