Preview

11 - Overriding and Overloading

 1. When two or more methods (functions) in the same Class have the same name but different parameters,this is called method _________
Video on overriding

  None of the above

  overriding

  overloading

  overkilling

 2. Analyse the following code snippet. What is the output?
class A:
                def sayhi(self):
                                print("I'm in A")                          
class B(A):
                def sayhi(self):
                                print("I'm in B")                             
bobj=B()
bobj.sayhi()

  "I'm in B" demonstrating deletion of methods

  "I'm im B" - demonstrating overriding

  None of the above

  "I'm in A" demonstrating overloading

 3. In this example a subclass is _________________________ of a method in the superclass.
class A:
                def sayhi(self):
                                print("I'm in A")                          
class B(A):
                def sayhi(self):
                                print("I'm in B")                             
bobj=B()
bobj.sayhi()

  comparing the rules

  keeping the functionality the same

  changing the functionality

  deleting the functionality

 4. Method Overloading happens at compile time while Overriding happens at runtime

  TRUE

  FALSE

 5. In a class, there can be several methods with the same name. However they must have a different signature. A signature is__________________

  the same thing as a variable or an argument

  comprised of its name, its parameter types and the order of its parameters.

  the object's name

  not part of a class or object

 6. The practice of defining ______________ within the same class that share the same name but have different parameters is called overloading methods.

  a single method

  two or more inherited classes

  a single object

  two or more methods

 7. It is possible for the constructor to be overloaded. This can happen if you _______________
Video on overloading

  define more than one constructor with different parameters

  None of the above

  define a single constructor with multiple parameters

  define multiple constructors with the same parameters

 8. If we define a method that exists in the super class and we override the super class method, it is called called class overloading.
Note: Although a method signature has to be unique inside a class, the same method signature can be defined in different classes

  TRUE

  FALSE

 9. Method overriding happens with methods with the same name and same signature between inherited classes.

  FALSE

  TRUE

 10. operator overloading, sometimes termed operator ad hoc ______________, is where different operators have different implementations depending on their arguments.

  abstraction

  polymorphism

  inheritance

  encapsulation

 11. In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different implementations
Video on Function Overloading

  FALSE

  TRUE

 12. Overriding is where a __________ can have a different execution for a method compared with the same named method for the base class.

  created object

  sub class

  base object

  parent class

 13. Most experts would suggest that Python doesn't (obviously) support method overloading.

  TRUE

  FALSE

 14. Overloading refers to an item ___________________. Operator names are often overloaded.
 For instance, the plus sign (+) refers to addition of integers, addition of singles, addition of doubles, and concatenation of strings. 

  None of the above

  being used in more than one way

  being used in the exact same way as in the super class

  being used in only one way

 15. To demonstrate overriding, it is not necessary at all (or not typical) to use inheritance.

  TRUE

  FALSE