summary refs log tree commit diff stats
path: root/java/text/RuntimePolymorphismExample.typ
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@termux-alpine>2024-01-28 06:38:55 +0000
committerSudipto Mallick <smlckz@termux-alpine>2024-01-28 06:38:55 +0000
commitfc4d96a9e3e20f8ddf035c16fc32b1effb75481b (patch)
tree4e13b2606e94e2098d1a288b051603cfc36d983b /java/text/RuntimePolymorphismExample.typ
parentcd6a9243c056710794549a1ab5d51fbdd082ce2e (diff)
downloadzadania-fc4d96a9e3e20f8ddf035c16fc32b1effb75481b.tar.gz
Complete all Java assignments
Diffstat (limited to 'java/text/RuntimePolymorphismExample.typ')
-rw-r--r--java/text/RuntimePolymorphismExample.typ31
1 files changed, 31 insertions, 0 deletions
diff --git a/java/text/RuntimePolymorphismExample.typ b/java/text/RuntimePolymorphismExample.typ
new file mode 100644
index 0000000..1235c27
--- /dev/null
+++ b/java/text/RuntimePolymorphismExample.typ
@@ -0,0 +1,31 @@
+#import "/template.typ": *
+#show: A => apply(A)
+#set raw(lang: "java-new")
+#set par(leading: 0.7em)
+
+#assignment(21)[
+  Write a program, wherein create an Interface and create two sub-classes implementing the interface to show the functionalities of runtime polymorphism (_a.k.a._ dynamic method dispatch) using them.
+]
+
+#scos("RuntimePolymorphismExample")
+
+=== Discussion
+
+#skind[Interfaces, classes and methods implemented in the program]
+
+- Interface `Shape`:
+  - `void draw()`: Declares a method.
+
+- Class `Circle` (implements `Shape`):
+  - Implements the `draw()` method from the `Shape` interface.
+  - Method `void calculateArea()`: Declares a specific method for calculating the area of a circle.
+
+- Class `Square` (implements `Shape`):
+  - Implements the `draw()` method from the `Shape` interface.
+  - Method `void calculateArea()`: Declares a specific method for calculating the area of a square.
+
+- Class `RuntimePolymorphismExample`:
+  - `public static void main(String[])`: Contains the main program demonstrating runtime polymorphism by creating objects of subclasses (`Circle` and `Square`) and calling the `draw()` method dynamically.
+
+  
+#signature()