forked from AndrewProgramming/JavaTutorialCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSayableDemo.java
More file actions
35 lines (27 loc) · 785 Bytes
/
SayableDemo.java
File metadata and controls
35 lines (27 loc) · 785 Bytes
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
package java8;
interface Sayable {
// Default method
default void say() {
System.out.println("Hello, this is default method");
}
// Abstract method
void sayMore(String msg);
static void sayLounder(String msg){
System.out.println(msg);
}
}
public class SayableDemo implements Sayable {
public void sayMore(String msg) { // implementing abstract method
System.out.println(msg);
}
@Override
public void say() {
System.out.println("my say");
}
public static void main(String[] args) {
Sayable dm = new SayableDemo();
dm.say(); // calling default method
dm.sayMore("Work is worship"); // calling abstract method
Sayable.sayLounder("say lounder!");
}
}