Week 11 Flashcards
New attributes and methods may be added to a subclass.
True
One problem with using a UML diagram is that there is no way to indicate inheritance.
false lol the whole point of the diagram is to show inheritance
When a class inherits another class, it is required to use all the data attributes and methods of the superclass.
False
Polymorphism works on any two class methods that have the same name.
True
A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
False
A subclass may not override any method other than the __init__ method.
False
Each subclass has a method named __init__ that overrides the superclass’s __init__ method.
True
In a UML diagram depicting inheritance, you only need to write the name of the subclass.
False
An “is a” relationship exists between a grasshopper and a bumblebee.
False
An “is a” relationship exists between a wrench and a tool.
__________ allows a new class to inherit members of the class it extends.
a. Encapsulation
b. Attributes
c. Methods
d. Inheritance
inheritance
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. Polymorphism
What does a subclass inherit from a superclass?
a. instances and attributes
b. objects and methods
c. methods and instances
d. attributes and methods
attributes and methods
In a UML diagram, what does the open arrowhead point to?
a. the superclass
b. the subclass
c. the object
d. a method
The superclass
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. superclass