Concept explainers
To explain how the polymorphism enables “in general” rather than specific ad also to explain its key advantages in
Explanation of Solution
Polymorphism is a Greek word where ‘poly’ means many and ‘morphism’ means forms. Thus, polymorphism is defined as the ability to acquire many forms. It can be used to develop programs which processes class objects that belong to same hierarchy of class as if all objects belong to base class in the hierarchy.
In polymorphism the base class object is set equal to the sub class objects. Thus, the base class behaves differently depending upon the functionality of sub classes.
Polymorphism helps us to ‘program in general’ and not ‘in specific’.
The advantages enabled by Polymorphism to program ‘in the general’ are given below:
- It focuses on general operations applied to all objects constructed from a class in the class hierarchy.
- It helps provide a general behavior in the code that can be used by all subclasses besides the specific code of each subclass that distinguish their functionality.
- It enables us to separate the general code from the specific code.
- It also facilitates the code extension by including new features in the class without such modification.
- The base class contains a set of member functions which all the subclasses inherit and provide their own definitions.
The advantages of programming “in general” are given below:
- It supports the re-usability of the code.
- The code can be easily extended and new functionality can be added to the existing code without such modification.
- It also helps in reducing the complexity of the code.
- It provides robustness in the program.
Want to see more full solutions like this?
Chapter 20 Solutions
C How to Program (8th Edition)
- Explain how composition contributes to reusability. Distinguish between IS-A and Has-A rules.arrow_forwardPlease explain parametric polymorphism and provide an example of a subprogram that uses it.arrow_forward(2) luhäi The ability of a function or operator to act in different ways on different datatypes is called overloading O abstract data type inheritance polymorphism هذا السؤال مطلوبarrow_forward
- (a) . Explain the concept of inline function and static member function in details with program.(b) • Explain the difference b/w object oriented and procedural programming language in detail.arrow_forwardTo what extent do Class and Structure vary in their practical application?arrow_forwardSpecify true (T) or false (F) for each of the following statements.(a) In dynamically typed languages, a type error is unnoticed if the statement containing the error is neverexecuted.Answer: true false(b) In OCaml fold right is tail recursive while fold left is not.Answer: true false(c) Immutability fits the functional programming paradigm. Mutability fits the imperative programmingparadigm.Answer: true false(d) Higher order functions are the functions that run with higher than O(n) time complexity.Answer: tree false(e) In every programming language, code must be compiled before it is run.Answer: true false(f) Every language that is a regular language is also a context-free language.Answer: true false(g) Regular expression and finite state automaton are equivalently powerful.Answer: true false(h) Lambda calculus is Turing-complete.Answer: true falsearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education