-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfacePrgWIthConcept.java
More file actions
35 lines (35 loc) · 1.17 KB
/
InterfacePrgWIthConcept.java
File metadata and controls
35 lines (35 loc) · 1.17 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
/*
NOTE:
1) all the methods of interface are abstract methods (which does not have body).
2) after implementing interface all the method of it must be overridden.
3) difference between abstract and interface is that
abstract is a class so there is no multiple inheritance and interface have access to multiple inheritance
means: we can create a class by implementing multiple interfaces.
4) variables in the interfaces are final so you can't change them.
5) while overriding the method of interface they should be declare as public.
*/
interface camera{
public int a=10;
void click();
}
interface torch{
void on();
}
class mobile implements camera,torch{
protected int a=14; //but you can override the properties .
public void click(){
System.out.println("Photo is clicked.");
}
public void on(){
System.out.println("Torched in turning on.");
}
}
public class InterfacePrgWIthConcept {
public static void main(String[] args) {
mobile m=new mobile();
m.click();
m.on();
// m.a=13; //we cannot assign value to the final variable.
System.out.println(m.a);
}
}