repl.it
@kenanhancer/

PolymorphismDemo7

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Main {
  public static void main(String[] args) {
    Bike bike1 = new Splendor(); // Upcasting
    bike1.run();
  }
}

class Bike {
  void run() {
    System.out.println("running");
  }
}

class Splendor extends Bike{
  void run(){
    System.out.println("running safely with 60km");
  }
}
?