The following program draws squares recursively. Fill in the missing code.

```
import javax.swing.*;
import java.awt.*;

public class Test extends JApplet {
public Test() {
add(new SquarePanel());
}

static class SquarePanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);

int width = (int)(Math.min(getWidth(), getHeight()) * 0.4);
int centerx = getWidth() / 2;
int centery = getHeight() / 2;

displaySquares(g, width, centerx, centery);
}

private static void displaySquares(Graphics g, int width,
int centerx, int centery) {
if (width >= 20) {
g.drawRect(centerx - width, centery - width, 2* width, 2 * width);
displaySquares(_________, width - 20, centerx, centery);
}
}
}
}```
a. getGraphics()
b. newGraphics()
c. null
d. g


d

Computer Science & Information Technology

You might also like to view...

An uncaught exception ________.

a. is a possible exception that never actually occurs during the execution of the program. b. is an exception that occurs for which the matching catch clause is empty. c. is an exception that occurs for which there are no matching catch clauses. d. is another term for a thrown exception.

Computer Science & Information Technology

A thin client power supply is most likely ______ to/than a typical home theater PC power supply

A) Less powerful B) More powerful C) Equal in power D) Quieter E) Cooler-running

Computer Science & Information Technology

You should use the same abbreviation throughout a document.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Answer the following statements true (T) or false (F)

1. The order of actions in an algorithm is irrelevant. 2. An algorithm specifies only the order in which to solve a problem. 3. Programs can be written, compiled and executed with pseudocode. 4. Pseudocode normally describes only executable statements. 5. Pseudocode helps you conceptualize a program during the design process.

Computer Science & Information Technology