| 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 7 students
Accessor Method Header
< Prev
Next >

Consider the following class definition.

public class Example
{
    private int x;
    // Constructor not shown.
}

Which of the following method headers, if added to the Example class, would allow other classes to access the value of the private instance variable x?

A

public void getX(int x)

B

public void getX()

C

private int getX()

D

public int getX()

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
#1kaisuki11 0m 00s 100
#2y.seong202712 8m 33s -423
#3bommasam00044 37m 37s -1,857
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: apfive@apfive.org|Privacy Policy