Skip to content

Commit 225db03

Browse files
authored
Create 20_Interfaces in java
1 parent 3499376 commit 225db03

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

20_Interfaces in java

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.company;
2+
3+
interface Bicycle{
4+
int a = 64;
5+
void applyBrake(int decrement);
6+
void speedUp(int increment);
7+
}
8+
9+
class AvonCycle implements Bicycle {
10+
void blowHorn() {
11+
System.out.println("Honk");
12+
}
13+
14+
public void applyBrake(int decrement) {
15+
System.out.println("Applying Brake");
16+
}
17+
18+
public void speedUp(int increment) {
19+
System.out.println("Increasing Speed");
20+
}
21+
}
22+
public class Interfaces {
23+
public static void main(String[] args) {
24+
AvonCycle cycle = new AvonCycle();
25+
cycle.applyBrake(1);
26+
cycle.blowHorn();
27+
cycle.speedUp(3);
28+
29+
//cycle.a = 64; // You cannot modify the properties in Interface as they are final
30+
31+
System.out.println(cycle.a);
32+
}
33+
}

0 commit comments

Comments
 (0)