HackerRank Java Method Overriding 2 (Super Keyword) problem solution

In this HackerRank Java Method Overriding 2 (Super Keyword) problem solution, we need to modify the code so that the code prints the text on the output screen.

HackerRank Java Method Overriding 2 (Super Keyword) problem solution

HackerRank Java Method Overriding 2 (Super Keyword) problem solution.

import java.util.*;
import java.io.*;


class BiCycle
{
String define_me()
{
return "a vehicel with pedals.";
}
}

class MotorCycle extends BiCycle
{
String define_me()
{
return "a cycle with an engine.";
}

MotorCycle()
{


System.out.println("Hello I am a motorcycle, I am "+ define_me());
String temp=super.define_me();
System.out.println("My ancestor is a cycle who is "+ temp );
}

}
class Solution{
public static void main(String []argh)
{
MotorCycle M=new MotorCycle();
}
}


Post a Comment

0 Comments