You can make a triangle with drawShape() code like this:
Rectangle2D rect = getBoundingRect();
double x1 = rect.getMinX();
double y1 = rect.getMinY();
double x2 = x1 + rect.getWidth();
double y2 = y1;
double x3 = x1;
double y3 = y1 + rect.getHeight();
double xs[] = new double[] {x1, x2, x3};
double ys[] = new double[] {y1, y2, y3};
g.strokePolygon(xs, ys, 3);
If you want a triangle with the top corner pointing up, then you can do this instead:
Rectangle2D rect = getBoundingRect();
double x1 = rect.getMinX()+ rect.getWidth()/2;
double y1 = rect.getMinY();
double x2 = rect.getMinX() + rect.getWidth();
double y2 = rect.getMinY()+ rect.getHeight();
double x3 = rect.getMinX();
double y3 = rect.getMinY()+ rect.getHeight();
double xs[] = new double[] {x1, x2, x3};
double ys[] = new double[] {y1, y2, y3};
g.strokePolygon(xs, ys, 3);
Then it would be possible to make an equilateral triangle if you create a Triangle with a height that is equal to the width * sqrt(3) / 2 ... but the practice exam is not really meant to test your geometry skills. Any kind of triangle you can draw is fine, as long as it is within the "bounding box" for the figure.