Object-Oriented Programming · Question 17 · Easy

Inside an instance method or constructor in Java, which keyword refers to the current object?

  1. super
  2. self
  3. current
  4. this
Answer and explanation

Answer: D. this

Explanation: this refers to the object on which the method was called, for example this.name = name in a constructor. super refers to the parent-class part of the object, and self is Python's convention.

Previous: A Logger class keeps a list of log entries in a private field and offers only… · Next: Inheritance, as in 'SavingsAccount extends Account', models which kind of…

Practise object-oriented programming

Try a fresh set of object-oriented programming questions with an explanation after every answer, free and without signing up: Object-Oriented Programming practice. Or sit a full placement mock test.

More object-oriented programming questions

More technical & programming practice

DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge