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 text(){
return " with pedals.";
}
}
class moto extends bicycle{
String text(){
return " an engine.";
}
moto(){
System.out.println("Hello I am a motorcycle, I am a cycle with"+ text());
String ss = super.text();
System.out.println("My ancestor is a cycle who is a vehicle"+ ss);
}
}
public class Solution {
public static void main(String[] args) {
moto bi = new moto();
}
}
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 →
my code:
import java.io.; import java.util.;
class bicycle { String text(){ return " with pedals.";
}
class moto extends bicycle{ String text(){ return " an engine.";
}
public class Solution {
}