-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolymorphismTest2.java
More file actions
50 lines (38 loc) · 887 Bytes
/
Copy pathPolymorphismTest2.java
File metadata and controls
50 lines (38 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.intellect.oops;
class AutoMobiles{
public void rider() {
System.out.println("Rider: riding...");
}
}
class LandVehicles extends AutoMobiles{
public void rider() {
System.out.println("Rider: riding..LandVehicles.");
}
}
class Car extends LandVehicles{
public void rider() {
System.out.println("Rider: riding.car..");
}
}
class Bike extends LandVehicles {
public void rider() {
System.out.println("Rider: riding..Bike.");
}
}
class RoyalEnfield extends Bike {
public void rider() {
System.out.println("Rider: riding..RoyalEnfield.");
}
}
public class PolymorphismTest2 {
public static void main(String[] args) {
LandVehicles v = new LandVehicles();
v.rider();
Car car= new Car();
car.rider();
Bike b = new Bike();
b.rider();
RoyalEnfield rf= new RoyalEnfield();
rf.rider();
}
}