1.

What is the use of duck typing?(a) More restriction on the type values that can be passed to a given method(b) No restriction on the type values that can be passed to a given method(c) Less restriction on the type values that can be passed to a given method(d) Makes the program code smallerI had been asked this question in an international level competition.My question is based upon Polymorphism in portion Classes and Objects, Inheritance, Polymorphism, Encapsulation and Exception Handling of Python

Answer»

The correct choice is (C) Less restriction on the type values that can be passed to a given method

The explanation: In PYTHON, any set of classes with a COMMON set of methods can be treated similarly. This is called duck TYPING. Hence duck typing imposes less restrictions.



Discussion

No Comment Found

Related InterviewSolutions