-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Interfaces_Java8.java
More file actions
57 lines (44 loc) · 1.05 KB
/
Test_Interfaces_Java8.java
File metadata and controls
57 lines (44 loc) · 1.05 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
package com.May2023;
public class Test_Interfaces_Java8 implements ITest1 , ITest28
{
/*public void test()
{
System.out.println("in a default method");
}*/
public static void main(String[] args)
{
Test_Interfaces_Java8 j8 = new Test_Interfaces_Java8();
j8.test();
ITest1.staticTest();
}
//The compiler will force to override atleast one of the default methods in the 2 interfaces being implemented
@Override
public void test() {
// TODO Auto-generated method stub
ITest1.super.test();
}
/*@Override
public void test() {
// TODO Auto-generated method stub
ITest1.super.test();
}*/
}
interface ITest1
{
//default keyword was introduced in java 8 for default methods introduced in Interfaces
default void test()
{
System.out.println("in a default method: 'ITEST1'");
}
static void staticTest()
{
System.out.println("In a static method: 'ITEST1'");
}
}
interface ITest28
{
default void test()
{
System.out.println("in a default method: 'ITEST2'");
}
}