summaryrefslogtreecommitdiff
path: root/output/ex22.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-05-10 14:47:48 -0600
committerbd-912 <bdunahu@colostate.edu>2024-05-10 14:47:48 -0600
commitb8c16f5ff7dffd1ceb51d2115aa2f86a59f090fe (patch)
tree8f93132b109873f34b7c7c5bba74e0bb3eb73333 /output/ex22.java
parent94254471915826aa8759df483f0b75624d740784 (diff)
More examples for overriding class attributes
Diffstat (limited to 'output/ex22.java')
-rw-r--r--output/ex22.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/output/ex22.java b/output/ex22.java
new file mode 100644
index 0000000..6163dec
--- /dev/null
+++ b/output/ex22.java
@@ -0,0 +1,25 @@
+class Overriding {
+ public static void main(String[] args) {
+ System.out.println(new A().init());
+ }
+}
+
+class A {
+ boolean x ;
+
+ public int init() {
+ return 0;
+ }
+
+ public int x(A a) {
+ return 1;
+ }
+}
+
+class B extends A {
+ int x;
+ public int x(A a) {
+ x = 2 ;
+ return x ;
+ }
+}