Dear friends,

I feel a bit not confident about the scope of a variable and argument and wish to confirm with you.

Suppose I have the following fields and methods in my class:

Code:
public class BinaryCalculator extends JApplet implements ActionListener {
   Number op1 = new Number();
   Number op2 = new Number();

   public String add(Number op1, Number op2) {
          ...
       return op1 + op2
   }

   public String subtract(Number op1, Number op2) {
          ...
       return op1 - op2
   }

   public void actionPerformed(ActionEvent e) {
      try {
         // Actions for Number keys
         if (e.getActionCommand() == "1") {
             op1 = 1
         }
         if (e.getActionComand() == "ADD") {
             add("10","12")
         }
         ...
    }
}
In the above code, I use arguments of the same names as the outside fields op1, op2, will this
(1) cause error because the methods will modify the op1, op2 outside; or
(2) the op1, op2 in the methods (add, subtract) will simply treat them as local and can't see the outside op1, op2, thus no problem.

Also, if I declare in this way, what is the access modifier for op1 and op2, public or private?

If the .java file contains more than 1 class, is it only one of them can be public? Thanks

Thanks a lot.