| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. The output of the two codes shown below is exactly the same. State whether true or false. object 'a' CODE 1 >>> pickle.dumps('a', 3) CODE 2 >>> pickle.dumps(object, 3)

Correct Answer is : TRUE

2. Which of the following functions can accept more than one positional argument?

Correct Answer is : pickle.dumps

3. Which of the following functions raises an error when an unpicklable object is encountered by Pickler?

Correct Answer is : pickle.PicklingError

4. The pickle module defines ______ exceptions and exports _______ classes.

Correct Answer is : 45353

5. Which of the following cannot be pickled?

Correct Answer is : Functions which are defined at the top level of a module with lambda

6. If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.

Correct Answer is : False value

7. Lambda functions cannot be pickled because:

Correct Answer is : All lambda functions have the same name, that is,

8. The module _______________ is a comparatively faster implementation of the pickle module.

Correct Answer is : cPickle

9. The copy module uses the ___________________ protocol for shallow and deep copy.

Correct Answer is : pickle

10. Which of the following best describes polymorphism?

Correct Answer is : Allows for objects of different types and behaviour to be treated as the same general type

11. What is the biggest reason for the use of polymorphism?

Correct Answer is : The program will have a more elegant design, and will be easier to maintain and update

12. What is the use of duck typing?

Correct Answer is : Less restriction on the type values that can be passed to a given method

13. What is the output of the following piece of code? class A: def __str__(self): return '1' class B(A): def __init__(self): super().__init__() class C(B): def __init__(self): super().__init__() def main(): obj1 = B() obj2 = A() obj3 = C() print(obj1, obj2,obj3) main()

Correct Answer is : 36892

14. What is the output of the following piece of code? class Demo: def __init__(self): self.x = 1 def change(self): self.x = 10 class Demo_derived(Demo): def change(self): self.x=self.x+1 return self.x def main(): obj = Demo_derived() print(obj.change())   main()

Correct Answer is : 2

15. A class in which one or more methods are only implemented to raise an exception is called an abstract class. True or False?

Correct Answer is : TRUE

16. Overriding means changing behaviour of methods of derived class methods in the base class. Is the statement true or false?

Correct Answer is : FALSE

17. What is the output of the following piece of code? class A: def __repr__(self): return "1" class B(A): def __repr__(self): return "2" class C(B): def __repr__(self): return "3" o1 = A() o2 = B() o3 = C() print(obj1, obj2, obj3)

Correct Answer is : 37623

18. What is the output of the following piece of code? class A: def __init__(self): self.multiply(15) print(self.i)   def multiply(self, i): self.i = 4 * i; class B(A): def __init__(self): super().__init__()   def multiply(self, i): self.i = 2 * i; obj = B()

Correct Answer is : 30

19. What is the output of the following piece of code? class Demo: def check(self): return " Demo's check " def display(self): print(self.check()) class Demo_Derived(Demo): def check(self): return " Derived's check " Demo().display() Demo_Derived().display()

Correct Answer is : Demo’s check Derived’s check

20. What is the output of the following piece of code? class A: def __init__(self): self.multiply(15) def multiply(self, i): self.i = 4 * i; class B(A): def __init__(self): super().__init__() print(self.i)   def multiply(self, i): self.i = 2 * i; obj = B()

Correct Answer is : 30