biryu2205 / Biryu

0 stars 0 forks source link

Hackerrank Java Method Overriding 2 (Super Keyword) #79

Closed biryu2205 closed 6 years ago

biryu2205 commented 6 years ago
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());
    String temp = super.define_me();
    System.out.println("My ancestor is a cycle who is " + temp);
  }
}

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