- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfacesInJava.java
More file actions
Latest commit
46 lines (42 loc) · 1.23 KB
/
Copy pathInterfacesInJava.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
interfaceBicycle{
inta = 45;
voidapplyBrake(intdecrement);
voidspeedUp(intincrement);
}
interfaceHornBicycle{
intx = 45;
voidblowHornK3g();
voidblowHornmhn();
}
classAvonCycleimplementsBicycle, HornBicycle{
//public int x = 5;
voidblowHorn(){
System.out.println("Pee Pee Poo Poo");
}
publicvoidapplyBrake(intdecrement){
System.out.println("Applying Brake");
}
publicvoidspeedUp(intincrement){
System.out.println("Applying SpeedUP");
}
publicvoidblowHornK3g(){
System.out.println("Kabhi khushi kabhi gum pee pee pee pee");
}
publicvoidblowHornmhn(){
System.out.println("Main hoon naa po po po po");
}
}
publicclassInterfacesInJava {
publicstaticvoidmain(String[] args) {
AvonCyclecycleHarry = newAvonCycle();
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();
}
}