415,475 views
33 votes
33 votes
Java uses to reference the current object.group of answer choices

A. this
B. that
C. thisObject
C. D. null

User Chirag Ghori
by
3.0k points

1 Answer

12 votes
12 votes

Answer:

B. this

Step-by-step explanation:

In a constructor for example, this.x will refer to the current object's variable(s).

public class Main {

int x;

// Constructor with a parameter

public Main(int x) {

this.x = x;

}

// Call the constructor

public static void main(String[] args) {

Main myObj = new Main(5);

System.out.println("Value of x = " + myObj.x);

}

}

User Kicaj
by
2.6k points