this and super
this refers to the current object and super to the parent.
Example
public class Main {
static class Parent { String who() { return "parent"; } }
static class Child extends Parent { String who() { return "child+" + super.who(); } }
public static void main(String[] args) {
Child c = new Child();
System.out.println(c.who());
}
}Result
child+parent
Exercise
Parent reference.
.who()Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.