We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
class BiCycle{
String define_me(){
return "a vehicle 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());
BiCycle bi=new BiCycle();
String temp=bi.define_me(); //Fix this line
System.out.println("My ancestor is a cycle who is "+ temp );
}
}
class Solution{
public static void main(String []args){
MotorCycle M=new MotorCycle();
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Method Overriding 2 (Super Keyword)
You are viewing a single comment's thread. Return to all comments →
----->>>> java
import java.util.; import java.io.;
class BiCycle{ String define_me(){ return "a vehicle with pedals."; } }
class MotorCycle extends BiCycle{ String define_me(){ return "a cycle with an engine."; }
} class Solution{ public static void main(String []args){ MotorCycle M=new MotorCycle(); } }