Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.) \"If a super class and a subclass both have a method with the same name and

ID: 3885452 • Letter: 1

Question

1.) "If a super class and a subclass both have a method with the same name and number of parameters, _____."

we say the subclass method overrides the superclass method.

we say the methods have the same essence

we say the methods have the same thumbprint

2.) Consider the code below. Which statement is the list comprehension equivalent of the following for-loop.

n = [10, 6, 10, 4]

m = []

for x in n:

m.append(x/2)

m = [x/2 for x in n]

m = [x/2 for m in n]

m = [n/2 for x in m]

3.) "When using the wx.TextCtrl, how would you assign the value typed into the TextCtrl to a variable?

txt = self.txt1.GetValue()

txt = self.txt1.SetValue('xyz')

txt = self.txt1.GetText()

txt = self.txt1.GetText('xyz')

4.) Which of the following creates a status bar at the bottom of a wxPython window?

self.s = self.CreateStatusBar()

self.s = wx.StatusBar()

5.) With inheritance, often you will collect attributes and methods in the super class that are shared by your subclasses.

True

False

6.) When is an object constructor invoked?

When an object is created

When any instance data is modified

When any method is invoked

Only when multiple arguments are required to create an object

7.) If a method in the superclass has the same header as a method in the subclass _____.

we say the methods have the same signature

we say the methods have the same essence

we say superclass method overrides the subclass method

8.) The 'is-a' relationship _____

points only in the direction of super class to child class

points only in the direction of child class to super class

is not part of inheritance

9.) In wxPython, which position argument sets the item 40 pixels from the top of the window and 70 pixels from the left edge of the window?

pos = (70, 40)

pos = (40, 70)

10.) An HourlyEmployee class inherits from an Employee class. From inside the HourlyEmployee class, how would you call the displayPay() method of the parent class in Python 2.7?

super(HourlyEmployee, self).displayPay(self, hours, wage)

super().displayPay(self, hours, wage)

Parent.displayPay(self, hours, wage)

Employee.self.displayPay(self, hours, wage)

Explanation / Answer

1)

Overloading

When a method in a subclass has the same signature as a method in a superclass (same name, same parameters and same return type) we say that the method in the subclass overloading the method in the superclass.

The above phenomenon is called "Function Overloading". Function overloading is the phenomenon in which we create the function with same signature and return type in super and sub class.