Super keyword (calling constructors)

Outputs: Inside A constructor Inside B constructor Inside C constructor Why? When constructor C is called, it actually calls constructor B, which called constructor A. Likewise if we called constructor…

Continue Reading Super keyword (calling constructors)

Super keyword (calling superclass methods)

With the Super keyword, you can: Call superclass methods Call superclass constructors Look at the following example: This outputs: Exception in thread "main" java.lang.StackOverflowError at Square.getInformation(Test.java:30) at Square.getInformation(Test.java:30) at Square.getInformation(Test.java:30)…

Continue Reading Super keyword (calling superclass methods)

Method Overriding

A subclass method overrides its superclass method if it has the same name a parameter types as its superclass. Output: 4 sides You can notice the subclass and the superclass…

Continue Reading Method Overriding