MYPROGRAMMINGLAB WITH PEARSON ETEXT
MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 20, Problem 20.3E
Program Plan Intro

To explain how the polymorphism enables “in general” rather than specific ad also to explain its key advantages in programming.

Expert Solution & Answer
Check Mark

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?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…
make a screen capture showing the StegExpose results
Which of the following is not one of the recommended criteria for strategic objectives? Multiple Choice   a) realistic   b) appropriate   c) sustainable   d) measurable
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT