diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-05-10 14:47:48 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-05-10 14:47:48 -0600 |
commit | b8c16f5ff7dffd1ceb51d2115aa2f86a59f090fe (patch) | |
tree | 8f93132b109873f34b7c7c5bba74e0bb3eb73333 /output/ex22.java | |
parent | 94254471915826aa8759df483f0b75624d740784 (diff) |
More examples for overriding class attributes
Diffstat (limited to 'output/ex22.java')
-rw-r--r-- | output/ex22.java | 25 |
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 ; + } +} |