What is the scope of the field a in the following code:

public class Example
{
    private int a;

    public void doSomething()
    {
        a = 4;
    }
    public void setA(int value)
    {
        a = value;
    }
  }
Class-level scope
  • Local to the doSomething() method
  • Local to the setA() method
  • Local to both the setA() and doSomething() methods

Remember a variable can't be local to two methods!