From 2134a85661561e52f7521e1e4346686f3e8622af Mon Sep 17 00:00:00 2001 From: Hunor Vadasz-Perhat <112109309+HunorVadaszPerhat@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:55:41 +0200 Subject: [PATCH] Update readme.md --- super/readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/super/readme.md b/super/readme.md index 33aef6b..4fcee1c 100644 --- a/super/readme.md +++ b/super/readme.md @@ -1,9 +1,17 @@ ## Super - [Calling a superclass constructor](#calling-a-superclass-constructor) +- [Accessing method and variable of superclass](#accessing-method-and-variable-of-superclass) ### Calling a superclass constructor - can call a constructor in the superclass of the current class - often used in constructor chaining, where there are multiple constructors in a class that call each other using this(), and the final constructor calls a constructor in the superclass using super() ![Super call constructor](https://github.com/HunorVadaszPerhat/java_lang_specs/blob/main/images/super_call_constructor.png) + +### Accessing method and variable of superclass +- can access methods or variables in the superclass of the current class +- useful when there is a method or variable with the same name in both the superclass and subclass and the one in the superclass should be referred to + +![Accessing method and variable of superclass](https://github.com/HunorVadaszPerhat/java_lang_specs/blob/main/images/access_superclass_method_variable.png) +