COMP2396
Loading...
Searching...
No Matches
superthis.java
Go to the documentation of this file.
1class A {
2 public void function1() {
3 System.out.println("A Function 1");
4 }
5 public void function2() {
6 this.function1(); // "function1();" has the same effect
7 System.out.println("A Function 2");
8 }
9}
10
11class B extends A {
12 public void function1() {
13 System.out.println("B Function 1");
14 }
15 public void function2() {
16 super.function2();
17 System.out.println("B Function 2");
18 }
19}
20
21class superthis {
22 public static void main(String[] args) {
23 B obj = new B();
24 obj.function2();
25 /*
26 B Function 1
27 A Function 2
28 B Function 2
29 */
30 }
31}