Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What does the this keyword refer to in a constructor?
Think about the role of `this` when creating an object.
Why do we need this when parameters are named the same as instance variables?
Consider what happens if you don't use `this`.
What does the this keyword refer to in Java?
Think about how you address instance variables.
True or False: The this keyword can only be used in constructors.
Consider where else you might see `this` used.
Design a class Laptop that has model, brand, and year as its attributes. Create parameterized and default constructors, incorporating the this keyword appropriately.
Consider how you would differentiate attributes from parameters.
Write a program that creates an object of a Student class with name and id. Use the this keyword correctly to initialize the attributes.
Make sure your parameters match the instance variable names.
6 more questions in this section. Enroll free to practise them all.
Enroll free