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();
}
}
- What is the scope of the variable g?
- What is the scope of the variable p?
- Name all of the formal parameters declared in the program?(Hint: There are three, one of
which is very tricky to find.)
- Is there a comment in the program?
- Name all of the actual parameters in the program? (Hint: There are nine)
- Specifically what does the program do?
- What is the scope of the formal parameters x and y?
- Which identifiers refer to objects in the program?
- Which identifiers refer to classes in the program?
- Which identifiers refer to methods in the program?