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

  overloading

  overkilling

  None of the above

  overriding

 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

  "I'm in A" demonstrating overloading

  None of the above

 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

  deleting the functionality

  changing the functionality

  keeping the functionality the same

 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__________________

  not part of a class or object

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

  the same thing as a variable or an argument

  the object's name

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

  two or more methods

  a single object

  a single method

  two or more inherited classes

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

  define a single constructor with multiple parameters

  define more than one constructor with different parameters

  define multiple constructors with the same parameters

  None of the above

 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

  FALSE

  TRUE

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

  TRUE

  FALSE

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

  inheritance

  polymorphism

  encapsulation

  abstraction

 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.

  sub class

  base object

  parent class

  created object

 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 the exact same way as in the super class

  being used in more than one way

  being used in only one way

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

  FALSE

  TRUE