-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBike.java
More file actions
37 lines (33 loc) · 763 Bytes
/
Bike.java
File metadata and controls
37 lines (33 loc) · 763 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
package inheritance;
public class Bike {
public Bike(){
System.out.println("in Bike class");
}
void vehicleType(){
System.out.println("Bike");
}
}
class RoyalEnfield extends Bike{
public RoyalEnfield(){
System.out.println("in RoyalEnfield class");
}
void brand(){
System.out.println("Brand: RoyalEnfield");
}
}
class Himalaya extends RoyalEnfield{
public Himalaya(){
System.out.println("in Himalaya class ");
}
void speed(){
System.out.println("Speed: 120kmph");
}
}
class BikeImpl{
public static void main(String[] args) {
Himalaya himalaya = new Himalaya();
himalaya.vehicleType();
himalaya.brand();
himalaya.speed();
}
}