| preferred AP College board partner for AP classes
easy Solved by 6 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

private int getX()

B

public void getX()

C

public int getX()

D

public void getX(int x)

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

Question Leaderboard

Not enough data yet to show leaderboard.

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy