Asked by bano
Question 1
In the code below, there is an ambiguous reference in the constructor. The constructor is supposed to assign the value of the formal parameter to the class member variable x. Notice, however, that the formal parameter has the same name as the class member.
There is a way to get around this problem without changing either the class member variable or the formal parameter variable. Select the best answer from the choices below that would resolve this ambiguity. Note: the choices below replace the "???" in the assignment statement.
public class Point {
public int x = 0;
//constructor
public Point(int x) {
??? = x;
}
}
In the code below, there is an ambiguous reference in the constructor. The constructor is supposed to assign the value of the formal parameter to the class member variable x. Notice, however, that the formal parameter has the same name as the class member.
There is a way to get around this problem without changing either the class member variable or the formal parameter variable. Select the best answer from the choices below that would resolve this ambiguity. Note: the choices below replace the "???" in the assignment statement.
public class Point {
public int x = 0;
//constructor
public Point(int x) {
??? = x;
}
}
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.