The description of an attribute.
What is a variable that stores data about an object.
True or False: In polymorphism, two classes can have methods with the same name but different behaviors.
What is True?
The output of this code:
class Student:
def __init__(self):
self.grade = 11
s = Student()
print(s.grade)
What is 11?
An example of an attribute in a Student class.
What is a Name, grade level, student ID, or GPA.
The term for redefining a method in a subclass.
What is Method Overriding?
The output of this program:
class Animal:
def speak(self):
return "Sound"
class Dog(Animal):
def speak(self):
return "Woof"
d = Dog()
print(d.speak())
What is Woof?
Attribute that an Employee class might have that would identify a worker.
What is an Employee ID or Position.
A Shape class has a method called draw(). The subclasses Circle, Square, and Triangle each define their own version of draw(). The Object Oriented Program concept demonstrated is
What is Polymorphism
The parent class of this code:
class Person:
pass
class Teacher(Person):
pass
What is Person?
A car class has the attributes make, model, and year. Which of these attributes would most likely change when creating different Car objects.
What is any of them.
The code output is:
class Bird:
def speak(self):
return "Chirp"
class Duck(Bird):
def speak(self):
return "Quack"
class Owl(Bird):
def speak(self):
return "Hoot"
animals = [Duck(), Owl(), Bird()]
for a in animals:
print(a.speak())
What is Quack Hoot Chirp?
The output of the code is:
class Person:
def introduce(self):
return "I am a person"
class Student(Person):
def introduce(self):
return "I am a student"
p = Student()
print(p.introduce())
What is I am a student?
The point of attributes is
What is making code easier to manage, reuse, and maintain.
Polymorphisim is useful in programming for this reason.
What is making programs more flexible and reusable?
What is the object oreinted programming concept demonstrated by this code:
class Vehicle:
def move(self):
return "Moving"
class Car(Vehicle):
def move(self):
return "Driving"
class Boat(Vehicle):
def move(self):
return "Sailing"
What is Polymorphism?