| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
easy Solved by 6 students
Using 'this' in a Constructor
< Prev
Next >

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;

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1bommasam00033 0m 36s 264
#2kaisuki11 0m 00s 100
#3y.seong202712 0m 38s 52
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy