Using 'this' in a Constructor
Which of the following lines correctly assigns the parameter ‘total’ to the instance variable ‘total’ in the Calculator constructor?
public class Calculator {
private int total;
public Calculator(int total) {
// Missing line: assign parameter 'total' to the instance variable
// [Missing Line]
}
}
A
this.total = total;
B
this.total == total;
C
total = this.total;
D
Calculator.total = total;
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | bommasam000 | 3 | 3 | 0m 36s | 264 |
| #2 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #3 | y.seong2027 | 1 | 2 | 0m 38s | 52 |
Items per page:
10
1 – 3 of 3
APFIVE