-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterfaces_01.java
42 lines (30 loc) · 1.05 KB
/
Interfaces_01.java
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
// abstract class A {
// public abstract void show();
// public abstract void config();
// }
interface A {
// every variable in interface are by default final and static
int age = 44;
String area = "something";// final and static we can directly use interface variables
void show();
void config();
}
// instead of creating abstract class we can use interface, interface is not a
// class, everything in interface is public abstract
// class will impliment interface, in class we used extends keyword but we use
// implements here in case of implementing interfaces
class B implements A {
public void config() {
System.out.println("in show");
}
public void show() {
System.out.println("in config");
}
}
public class Interfaces_01 {
public static void main(String[] args) {
A obj; // we can create refrences but not object of interface,
System.out.println(A.age + A.area);
// A.area = "something"; //will give you an error
}
}