Topic 7.4: Working with Inheritance - Use super and this to access objects and constructors Flashcards

1
Q

How is the ‘this’ keyword used in Java?

A

This keyword is used to access the current instance of the class. It is especially helpful when disambiguating between instance variables and parameters with the same name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the ‘super’ keyword in Java do in the context of inheritance?

A

This keyword is used to access members of the superclass from within a subclass. It allows calling overridden or hidden methods and accessing fields defined in the superclass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

This keyword is used to access the current instance of the class. It is especially helpful when disambiguating between instance variables and parameters with the same name.

A

How is the ‘this’ keyword used in Java?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When can ‘super’ and ‘this’ be used to access constructors?

A

‘super()’ is used to call the constructor of the superclass from within the subclass constructor, and ‘this()’ is used to call another constructor within the same class, allowing constructor chaining.

Both must be the first statements in the constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

This keyword is used to access members of the superclass from within a subclass. It allows calling overridden or hidden methods and accessing fields defined in the superclass.

A

What does the ‘super’ keyword in Java do in the context of inheritance?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly