From cc0f63f4c15dbe5ed2a8bb7410c7623a017bfa7c Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:02:22 +0800 Subject: [PATCH 1/2] Committed on or around 2023/10/04 --- .../Interface/Interfaces_Can_Be_Extended.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Chapter8/Interface/Interfaces_Can_Be_Extended.java diff --git a/Chapter8/Interface/Interfaces_Can_Be_Extended.java b/Chapter8/Interface/Interfaces_Can_Be_Extended.java new file mode 100644 index 0000000..c101761 --- /dev/null +++ b/Chapter8/Interface/Interfaces_Can_Be_Extended.java @@ -0,0 +1,18 @@ +package Interface; + +interface A{ + + void meth1(); + void meth2(); +} + + + +public class Interfaces_Can_Be_Extended { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From fdd7c3de3831b4b30a87b1ef9f3ef5dcbbde3c05 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:12:36 +0800 Subject: [PATCH 2/2] Committed on or around 2023/10/04 --- .../Interface/Interfaces_Can_Be_Extended.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Chapter8/Interface/Interfaces_Can_Be_Extended.java b/Chapter8/Interface/Interfaces_Can_Be_Extended.java index c101761..69c49e7 100644 --- a/Chapter8/Interface/Interfaces_Can_Be_Extended.java +++ b/Chapter8/Interface/Interfaces_Can_Be_Extended.java @@ -1,17 +1,50 @@ package Interface; +// One interface can extend another. interface A{ void meth1(); void meth2(); } +// B now includes meth1() and meth2() - it adds meth3(). +interface B extends A{ // B inherits A. + void meth3(); +} + +// This class must implement all of A and B +class MyClass implements B{ + + @Override + public void meth1() { + // TODO Auto-generated method stub + System.out.println("Implement meth1(). "); + } + + @Override + public void meth2() { + // TODO Auto-generated method stub + System.out.println("Implement meth2(). "); + } + + @Override + public void meth3() { + // TODO Auto-generated method stub + System.out.println("Implement meth3(). "); + } +} public class Interfaces_Can_Be_Extended { public static void main(String[] args) { // TODO Auto-generated method stub + + MyClass obMyClass = new MyClass(); + + obMyClass.meth1(); + obMyClass.meth2(); + obMyClass.meth3(); }