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

Challenge 1: Override a Method Using the Super Function

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

Contents


More Related Answers

  • The Super Function
  • What would be the behavior if this() and super() used in a method?
  • how to call subclass override method in c++
  • Solution Review: Override a Method using the Super Keyword

  • Challenge 1: Override a Method Using the Super Function

    0

    Problem statement

    When a method in a derived class overrides a method in a base class, it is still possible to call the overridden method using the super() function.

    If you write super().method(), it will call the method that was defined in the superclass.

    You are given a partially completed code in the editor. Modify the code so that it returns the following:

    Sample input

    circle = XShape("Circle");

    circle.getName()

    Sample output

    "Shape, Circle"

    The Shape class is already prepended in the code and it has one property, sname and one method, getName(). getName() returns sname.

    Parent and child class structures

    Show hint

    Coding exercise

    First, take a close look, and then, design a step-by-step algorithm before trying the implementation. This problem is designed for your practice, so initially, try to solve it on your own. If you get stuck, you can always refer to the solution provided in the solution review. 

    Popularity 1/10 Helpfulness 1/10 Language python
    Source: Grepper
    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.