-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface_intro.java
More file actions
101 lines (81 loc) · 2.91 KB
/
interface_intro.java
File metadata and controls
101 lines (81 loc) · 2.91 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* interface_intro
*/
// interface Car { //interface islike classes only we cannot create a object of interface class
// void breakSystem(); //public //interface is fully abstract class
// void oilingSytem(); //public //and also we dont have to write abstract keywork in front of all methods
// }
// class BMWs implements Car{
// public void breakSystem(){ // // if in normal class we will write like this thanit will be default access modifier but in interface it will come under public
// System.out.println("Every car their should be a proper break system");
// }
// public void oilingSystem(){
// System.out.println("in every car their should be a proper oiling system");
// }
// public void powerSystem(){
// System.out.println("car should have a power system");
// }
// }
// public class interface_intro {
// public static void main(String[] args) {
// BMWs b1=new BMWs();
// b1.powerSystem();
// b1.oilingSystem();
// }
// }
// interface Car {
// void breakSystem();
// void oilingSystem();
// }
// class BMWs implements Car {
// public void breakSystem() {
// System.out.println("Every car should have a proper braking system");
// }
// public void oilingSystem() {
// System.out.println("Every car should have a proper oiling system");
// }
// public void powerSystem() {
// System.out.println("Every car should have a power system");
// }
// }
// public class interface_intro {
// public static void main(String[] args) {
// BMWs b1 = new BMWs();
// b1.powerSystem();
// b1.oilingSystem();
// }
// }
//////////////////////////////////////////////////////////////////
/*package whatever //do not write package name here */
import java.io.*;
interface Safety{
void safetyRule();
}
interface Car extends Safety{
void breakSystem(); // public
void OilingSystem(); // public
}
//private < protected < default < public
abstract class BMW implements Car{ //////if once we make a class abstracft in interface than their is no requirement of mkaing all the methods present in an inteface above the class
public void OilingSystem(){
System.out.println("i am oiling System of BMW");
}
public void powerSystem(){
System.out.println(" i have extra power for race");
}
public void safetyRule(){
System.out.println("you have to follow rules");
}
}
class BWMchild extends BMW {
public void breakSystem(){
System.out.println("breaking system");
}
}
class interface_intro {
public static void main (String[] args) {
BWMchild b1 = new BWMchild();
b1.powerSystem();
b1.breakSystem();
}
}