From the course: Oracle Java Certification: 3. Methods and Inheritance

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using super and this to reference objects and constructors

Using super and this to reference objects and constructors - Java Tutorial

From the course: Oracle Java Certification: 3. Methods and Inheritance

Start my 1-month free trial

Using super and this to reference objects and constructors

- [Instructor] There are two special keywords in Java, This and Super. They're important in the context of inheritance because This refers to the instance of the current class and Super provides access to the members defined in the immediate parent class. Each keyword can also be used with parentheses. This and Super with parentheses can be used to invoke constructors defined in the current class and the immediate parent class respectively. A constructor in any class must invoke one of the constructors in the immediate parent class using the Super keyword. If it is not done explicitly, the Java compiler will insert a call on the default constructor of the immediate parent class. If a class defines no constructor at all, the Java compiler will insert a default constructor that calls the default constructor of the immediate parent class. Chaining constructors in this fashion ensures that objects are properly constructed.…

Contents