Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Polymorphism | OOP
course content

Course Content

Java OOP

Challenge: PolymorphismChallenge: Polymorphism

Task

You are given a Parent class and a Child class that inherits from the Parent class. Your task is to override the parent method named method in the Child class so that it returns "This is the overridden method!".

Next, you need to overload this method by adding a parameter int parameter so that the method returns: "This is the overloaded method with int parameter: " + parameter.

Note that the methods should return these values, not display them on the screen!

Feel free to use the "Hint" and "Solution" buttons if you have difficulties understanding the task.

Link to the task: GitHub
Warning
Please do not modify the Parent class!
  • Open the src folder, then open the main/java/codefinity package.
  • There will be Parent and Child classes, open the Child class.
  • Use the @Override.
  • Use syntax: return "This is the overridden method!"; for the first method.
  • Overload this method by adding int parameter to the new one.
  • Use syntax return "This is the overloaded method with int parameter: " + parameter. for the second method;
  • Run tests by pressing the "Run Code" button.
  • Everything was clear?

    Section 2. Chapter 5
    course content

    Course Content

    Java OOP

    Challenge: PolymorphismChallenge: Polymorphism

    Task

    You are given a Parent class and a Child class that inherits from the Parent class. Your task is to override the parent method named method in the Child class so that it returns "This is the overridden method!".

    Next, you need to overload this method by adding a parameter int parameter so that the method returns: "This is the overloaded method with int parameter: " + parameter.

    Note that the methods should return these values, not display them on the screen!

    Feel free to use the "Hint" and "Solution" buttons if you have difficulties understanding the task.

    Link to the task: GitHub
    Warning
    Please do not modify the Parent class!
  • Open the src folder, then open the main/java/codefinity package.
  • There will be Parent and Child classes, open the Child class.
  • Use the @Override.
  • Use syntax: return "This is the overridden method!"; for the first method.
  • Overload this method by adding int parameter to the new one.
  • Use syntax return "This is the overloaded method with int parameter: " + parameter. for the second method;
  • Run tests by pressing the "Run Code" button.
  • Everything was clear?

    Section 2. Chapter 5
    some-alt