Challenge 1: Override a Method Using the Super Function
In this challenge, you will override a method using super().
We'll cover the following
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
.
Get hands-on with 1400+ tech skills courses.