Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Make things simpler with polymorphism#

Sumit Rawal answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • what is polymorphism
  • what is polymorphism
  • Polymorphism
  • What is Polymorphism?
  • polymorphism
  • can we say Polymorphism is a concept in OOP that allows data to be in multiple forms?
  • unity Polymorphism
  • Dynamic polymorphism example#
  • What is Polymorphism
  • What do you mean by Polymorphism ? Explain it with an example ?
  • does polymorphism allow reuse of code?
  • where do you use polymorphism in framework
  • asdasd
  • asdasd
  • Implementing Polymorphism Using Inheritance
  • asdasd

  • Make things simpler with polymorphism#

    0

    It would be better if all specific area calculation methods could be called getArea(). You would only have to remember one method name and when you call that method, the method specific to that object would be called. This can be achieved in object-oriented programming using polymorphism. The base class declares a function without providing an implementation. Each derived class inherits the function declaration and can provide its own implementation

    Consider that the Shape class has a method called getArea(), which is inherited by all subclasses mentioned. With polymorphism, each subclass may have its own way of implementing the method. For example, when the getArea() method is called on an object of the Rectangle class, the method will respond by displaying the area of the rectangle. On the other hand, when the same method is called on an object of the Circle class, the circle’s area will be calculated and displayed on the screen.

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: whatever
    Link to this answer
    Share Copy Link
    Contributed on May 17 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.