SCIENCE.
Trusted by students across multiple disciplines!
What is a Constructor? - Answer: Constructor is just like a method that is used to
initialize the state of an object. It is invoked at the time of object creation.
What is the super keyword? - Answer: The super keyword is used to invoke the
overridden method, which overrides one of its superclass methods. This keyword allows
to access overridden methods and also to access hidden members of the superclass.
It also forwards a call from a constructor, to a constructor in the superclass.
What is the "this" keyword? - Answer: The this keyword refers to the current instance of
the class.
What is required in order to use the super keyword? - Answer: Inheritance as the super
refers to the superclass (parent) class
Usages of the this keyword in Java? - Answer: There are 6 uses...
1) this can be used to refer to the current class instance variable
2)this can be used to invoke current class methods (implicitly)
3) this() can be used to invoke the current class constructor
4) this can be passed as an argument in a method call
5) this can be passed as arguments in the constructor call
6) this can be used to return the current class instance from a method.
(Look in the lesson for an example of each of these)
When can super be used? - Answer: Super can be used to...
1) refer to the immediate parent class instance variable.
2) invoke immediate parent class method.
1
APPHIA - Crafted with Care and Precision for Academic Excellence.