-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritanceInInterface.java
More file actions
40 lines (36 loc) · 1.04 KB
/
Copy pathInheritanceInInterface.java
File metadata and controls
40 lines (36 loc) · 1.04 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
package oops;
// This is a example for better understanding the inheritance concept in interface...
public class InheritanceInInterface {
public static void main(String[] args) {
Examples e = new Examples();
e.meth1();
e.meth3();
e.meth4();
}
}
// Declare a interface having the public, private and default method...
interface SampleInterface {
void meth1();
private void meth2(){
System.out.println("This is method 2, Which is declare as private.");
}
default void meth3() {
meth2();
System.out.println("This is method 3, Which is declare as default.");
}
}
// Declare second interface which extends another interface...
interface ChildSample extends SampleInterface{
void meth4();
}
// Declare a class which implements second interface...
class Examples implements ChildSample{
@Override
public void meth1(){
System.out.println("This is method 1.");
}
@Override
public void meth4(){
System.out.println("This is method 4.");
}
}