Skip to content

Commit 05cd527

Browse files
authored
Create InterfaceDemo.java
1 parent b05ca18 commit 05cd527

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
interface InterfaceDemo
2+
{
3+
// abstract method
4+
public void square();
5+
6+
// default method
7+
default void show()
8+
{
9+
System.out.println("This is a defult method");
10+
}
11+
}
12+
13+
class TestClass implements InterfaceDemo
14+
{
15+
// implementation of square abstract method
16+
public void square(int a)
17+
{
18+
System.out.println(a*a);
19+
}
20+
21+
public static void main(String args[])
22+
{
23+
TestClass d = new TestClass();
24+
d.square(4);
25+
26+
// default method executed
27+
d.show();
28+
}
29+
}

0 commit comments

Comments
 (0)