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.
Java Method Overriding 2 (Super Keyword)
Java Method Overriding 2 (Super Keyword)
Sort by
recency
|
110 Discussions
|
Please Login in order to post a comment
This is Write Code For This Problem !!!!
class Cycle { void print(String str){ System.out.println(str); } }
class Motorcycle extends Cycle { void print(String name){ super.print(name); System.out.println("My ancestor is a cycle who is a vehicle with pedals."); } }
public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Motorcycle M = new Motorcycle(); M.print("Hello I am a motorcycle, I am a cycle with an engine."); } }
import java.io.; import java.util.; class Cycle { void print() { System.out.println("Hello I am a motorcycle, I am a cycle with an engine."); } }
class Motorcycle extends Cycle { void print() { super.print(); // Call the overridden method in the superclass System.out.println("My ancestor is a cycle who is a vehicle with pedals."); } }
public class Main { public static void main(String[] args) { Motorcycle motorbike = new Motorcycle(); motorbike.print(); } }
String temp=super.define_me(); //Fix this line
----->>>> 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(); } }