CS 140 - Quiz 2 Name:__________________________________

Consider the following java program.

      import java.awt.*;
      public class Program {
      
        Graphics g;
        
        void draw(int x, int y) {
            g.setColor(Color.black);
            g.fillOval(x,y,200,200);
        }
      
        void run() {
           Picture p;
           p = new Picture(500,500);
           g = p.getGraphics();
           draw(50,50);
           p.repaint();
        }
        
        // DO NOT MODIFY CODE BELOW THIS LINE
        public static void main(String [] args) {
          Program prog = new Program();
          prog.run();
        }
      }
  1. What is the scope of the variable g?
  2. What is the scope of the variable p?
  3. Name all of the formal parameters declared in the program?(Hint: There are three, one of which is very tricky to find.)
  4. Is there a comment in the program?
  5. Name all of the actual parameters in the program? (Hint: There are nine)
  6. Specifically what does the program do?
  7. What is the scope of the formal parameters x and y?
  8. Which identifiers refer to objects in the program?
  9. Which identifiers refer to classes in the program?
  10. Which identifiers refer to methods in the program?