Practice mode Java

What does the keyword this refer to inside a Java instance method?

Correct answer C. The object on which the method was invoked

Explanation

Within an instance method or constructor, this is a reference to the current object, the one the method was invoked on. It does not mean the latest instance created, and it is not the class itself. Because no current object exists in a static context, using this inside a static method is a compile-time error.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.