summary refs log tree commit diff stats
path: root/java/text/InnerClassExample.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/InnerClassExample.typ
parentcd6a9243c056710794549a1ab5d51fbdd082ce2e (diff)
downloadzadania-fc4d96a9e3e20f8ddf035c16fc32b1effb75481b.tar.gz
Complete all Java assignments
Diffstat (limited to 'java/text/InnerClassExample.typ')
-rw-r--r--java/text/InnerClassExample.typ28
1 files changed, 28 insertions, 0 deletions
diff --git a/java/text/InnerClassExample.typ b/java/text/InnerClassExample.typ
new file mode 100644
index 0000000..796eac4
--- /dev/null
+++ b/java/text/InnerClassExample.typ
@@ -0,0 +1,28 @@
+#import "/template.typ": *
+#show: A => apply(A)
+#set raw(lang: "java-new")
+#set par(leading: 0.7em)
+
+#assignment(19, block: true)[
+  Write a program to create a class containing an inner class to show that inner class can use members of outer class directly, but the outer class can use members of inner class only through its objects. Check the name of the inner class file created when it was compiled.
+]
+#v(-1em)
+#scos("InnerClassExample")
+
+=== Discussion
+
+#skind[Classes and methods implemented in the program]
+
+- The `OuterClass` class:
+  - Private field `int outerMember`: Represents a member variable in the outer class.
+  - The `InnerClass` class:
+    - Private field `int innerMember`: Represents a member variable in the inner class.
+    - Method `void accessMembers()`: Prints the values of both outer and inner members.
+  - Method `void accessInnerMembers()`: Creates an instance of the inner class and prints the value of the inner member through the object.
+
+- The `InnerClassExample` class contains the main program:
+  - `public static void main(String[])`: Demonstrates the usage of outer and inner classes by creating instances and accessing their members.
+
+/ Note : The file name of the (bytecode) compiled class file corresponding to the inner class is ```text OuterClass$InnerClass.class```.
+  
+#signature()