...
/Solution Review: Override a Method using the Super Keyword
Solution Review: Override a Method using the Super Keyword
This review provides a detailed analysis to solve the 'Override a Method using the Super Keyword' challenge.
We'll cover the following...
Solution
Press + to interact
// Base Classclass Shape {// Private Data Membersprivate String name;public Shape() { // Default Constructorname = "Shape";}// Getter Functionpublic String getName() {return name;}}// Derived Classclass XShape extends Shape {private String name;public XShape(String name) { // Default Constructorthis.name = name;}// Overridden Methodpublic String getName() {return super.getName() + ", " + this.name;}}class Demo {public static void main(String args[]) {Shape circle = new XShape("Circle");System.out.println(circle.getName());}}