-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfacesInJava.java
More file actions
46 lines (42 loc) · 1.23 KB
/
InterfacesInJava.java
File metadata and controls
46 lines (42 loc) · 1.23 KB
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
interface Bicycle{
int a = 45;
void applyBrake(int decrement);
void speedUp(int increment);
}
interface HornBicycle{
int x = 45;
void blowHornK3g();
void blowHornmhn();
}
class AvonCycle implements Bicycle, HornBicycle{
//public int x = 5;
void blowHorn(){
System.out.println("Pee Pee Poo Poo");
}
public void applyBrake(int decrement){
System.out.println("Applying Brake");
}
public void speedUp(int increment){
System.out.println("Applying SpeedUP");
}
public void blowHornK3g(){
System.out.println("Kabhi khushi kabhi gum pee pee pee pee");
}
public void blowHornmhn(){
System.out.println("Main hoon naa po po po po");
}
}
public class InterfacesInJava {
public static void main(String[] args) {
AvonCycle cycleHarry = new AvonCycle();
cycleHarry.applyBrake(1);
// You can create properties in Interfaces
System.out.println(cycleHarry.a);
System.out.println(cycleHarry.x);
// You cannot modify the properties in Interfaces as they are final
// cycleHarry.a = 454;
//System.out.println(cycleHarry.a);
cycleHarry.blowHornK3g();
cycleHarry.blowHornmhn();
}
}