Deck 25: Graphics and Java 2d

Full screen (f)
exit full mode
Question
The fact that class Graphics is abstract contributes to Java's portability because ________.

A) drawing is performed differently on every platform that supports Java. A subclass of Graphics must be created that uses the drawing capabilities of the current platform.
B) objects of non-abstract classes can only be instantiated on the Windows platform.
C) drawing should not be performed on non-Linux platforms.
D) Class Graphics is not abstract.
Use Space or
up arrow
down arrow
to flip the card.
Question
The Java statement:
G.draw3DRect(290, 100, 90, 55, true);

A) draws a rectangle that appears to be raised (the top and left edges of the rectangle are slightly darker than the rectangle).
B) draws a rectangle that appears to be lowered (the bottom and right edges of the rectangle are slightly darker than the rectangle).
C) draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).
D) draws a rectangle that appears to be lowered (the top and left edges of the rectangle are slightly darker than the rectangle).
Question
Method getFont of class Graphics returns ________.

A) the current font name as a string
B) the font size in points
C) a Graphics object representing the current font
D) a Font object representing the current font
Question
Which of the following properly create and initialize a Font object? A. Font f = new Font();
B) Font f = new Font("Serif", Font.Bold + Font.Italic, 19);
C) Font f = new Font(Font.Bold, 20, "SansSerif");
D) Font f = new Font(20, Font.Bold, "Monospaced");

A) A and B.
B) B and C.
C) B.
D) D.
Question
GeneralPath method lineTo ________.

A) draws a line from the previous point in the GeneralPath object to the current point
B) draws a line with an arrow head to point to a GeneralPath object
C) moves the drawing origin around a line
D) specifies the first point in a GeneralPath object
Question
Which of the following statements is false?

A) A BufferedImage object uses the image stored in its associated TexturePaint object as the fill texture for a filled-in shape.
B) Class BufferedImage can be used to produce images in color and gray scale.
C) Class GradientPath draws a shape in a gradually changing color.
D) All of the above are true.
Question
The Java statement:
G.fillOval(290, 100, 90, 55);

A) Draws a filled oval with its center at coordinates x=290, y=100, with height=90 and width=55.
B) Draws a filled oval with its leftmost point at coordinates x=290, y=100, with height=90 and width=55.
C) Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates x=290, y=100, with width=90 and height=55.
D) Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates x=290, y=100, with height=90 and width=55.
Question
Which of the following is correct for font metrics?

A) height = descent + ascent + leading.
B) The amount the character dips below the baseline is the ascent.
C) The amount the character can be above the baseline is the leading.
D) The amount the character rises above the baseline is the descent.
Question
Which of the following statements about arcs is false?

A) An arc is drawn as a part of an oval.
B) Arcs sweep from a starting angle the number of degrees specified by their arc angle.
C) Arcs that sweep clockwise are measured in positive degrees.
D) None of the above statements are false.
Question
The JColorChooser dialog allows colors to be chosen by all but which of the following?

A) Swatches.
B) Hue, saturation, brightness.
C) Gradient, cycle, brightness.
D) Red, Green, Blue.
Question
In the Java coordinate system, the point (0, 0) is ________.

A) The lower-right corner of the screen.
B) The upper-right corner of the screen.
C) The lower-left corner of the screen.
D) The upper-left corner of the screen.
Question
Which of the following statements about the Java 2D API is true?

A) A Graphics2D object is instantiated to draw Java 2D figures.
B) Class Graphics2D is a subclass of class Graphics.
C) To access Graphics2D capabilities, cast the Graphics reference passed to paintComponent to a Graphics2D reference.
D) All of the above are true.
Question
Class FontMetrics declares methods that can be used to obtain the following font metrics ________.

A) ascent, descent and height
B) ascent, descent and leading
C) height and leading
D) All of the above.
Question
Which of the following statements about the Graphics object is true? A. The Graphics object is an argument to class Component's repaint method.
B) The Graphics object is instantiated by the user.
C) The Graphics object is the argument to a lightweight GUI component's paintComponent method.
D) The Graphics class is abstract.
E) The Graphics object manages a graphics context.

A) A, C, E.
B) C, D, E.
C) A, B, D, E.
D) All are true.
Question
A general path is ________.

A) a set of polylines that do not result in a closed shape
B) a shape constructed from straight lines and complex curves
C) the shape of the curve in a font's characters
D) represented by an object of class GraphicsPath
Question
The Graphics2D method(s) that determine(s) the color and texture for the shape to display is/are:

A) setStroke
B) setPaint
C) setTexture and setColor
D) setTexturePaint
Question
Which of the following are valid Java statements?
A. Color c = new Color(0, 255, 0);
B. Color c = new Color(0.0f, 1.0f, 0.0f);
C. Color c = new Color(0.0d, 1.0d, 0.0d);
D. setGreen;

A) All of the above.
B) A, B, C.
C) A, B, D.
D) A, B.
Question
Consider the code segment below:
int xValues[] = {100, 150, 200, 100};
Int yValues[] = {30, 130, 30, 30};
G.drawPolyline(xValues, yValues, 4);
What kind of figure does it draw?

A) A rectangle.
B) A triangle.
C) A V with its corner at the top.
D) A square.
Question
Consider the Java code segment below:
Polygon poly2 = new Polygon();
Poly2.addPoint(100, 30);
Poly2.addPoint(100, 130);
Which of the following will create a polygon that is a square?

A) poly2.addPoint(100, 60); poly2.addPoint(100, 130);
B) poly2.addPoint(200, 130); poly2.addPoint(200, 30);
C) poly2.addPoint(200, 60); poly2.addPoint(200, 130);
D) poly2.addPoint(100, 130); poly2.addPoint(100, 230);
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/19
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 25: Graphics and Java 2d
1
The fact that class Graphics is abstract contributes to Java's portability because ________.

A) drawing is performed differently on every platform that supports Java. A subclass of Graphics must be created that uses the drawing capabilities of the current platform.
B) objects of non-abstract classes can only be instantiated on the Windows platform.
C) drawing should not be performed on non-Linux platforms.
D) Class Graphics is not abstract.
drawing is performed differently on every platform that supports Java. A subclass of Graphics must be created that uses the drawing capabilities of the current platform.
2
The Java statement:
G.draw3DRect(290, 100, 90, 55, true);

A) draws a rectangle that appears to be raised (the top and left edges of the rectangle are slightly darker than the rectangle).
B) draws a rectangle that appears to be lowered (the bottom and right edges of the rectangle are slightly darker than the rectangle).
C) draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).
D) draws a rectangle that appears to be lowered (the top and left edges of the rectangle are slightly darker than the rectangle).
draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).
3
Method getFont of class Graphics returns ________.

A) the current font name as a string
B) the font size in points
C) a Graphics object representing the current font
D) a Font object representing the current font
D
4
Which of the following properly create and initialize a Font object? A. Font f = new Font();
B) Font f = new Font("Serif", Font.Bold + Font.Italic, 19);
C) Font f = new Font(Font.Bold, 20, "SansSerif");
D) Font f = new Font(20, Font.Bold, "Monospaced");

A) A and B.
B) B and C.
C) B.
D) D.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
5
GeneralPath method lineTo ________.

A) draws a line from the previous point in the GeneralPath object to the current point
B) draws a line with an arrow head to point to a GeneralPath object
C) moves the drawing origin around a line
D) specifies the first point in a GeneralPath object
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following statements is false?

A) A BufferedImage object uses the image stored in its associated TexturePaint object as the fill texture for a filled-in shape.
B) Class BufferedImage can be used to produce images in color and gray scale.
C) Class GradientPath draws a shape in a gradually changing color.
D) All of the above are true.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
7
The Java statement:
G.fillOval(290, 100, 90, 55);

A) Draws a filled oval with its center at coordinates x=290, y=100, with height=90 and width=55.
B) Draws a filled oval with its leftmost point at coordinates x=290, y=100, with height=90 and width=55.
C) Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates x=290, y=100, with width=90 and height=55.
D) Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates x=290, y=100, with height=90 and width=55.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is correct for font metrics?

A) height = descent + ascent + leading.
B) The amount the character dips below the baseline is the ascent.
C) The amount the character can be above the baseline is the leading.
D) The amount the character rises above the baseline is the descent.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following statements about arcs is false?

A) An arc is drawn as a part of an oval.
B) Arcs sweep from a starting angle the number of degrees specified by their arc angle.
C) Arcs that sweep clockwise are measured in positive degrees.
D) None of the above statements are false.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
10
The JColorChooser dialog allows colors to be chosen by all but which of the following?

A) Swatches.
B) Hue, saturation, brightness.
C) Gradient, cycle, brightness.
D) Red, Green, Blue.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
11
In the Java coordinate system, the point (0, 0) is ________.

A) The lower-right corner of the screen.
B) The upper-right corner of the screen.
C) The lower-left corner of the screen.
D) The upper-left corner of the screen.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following statements about the Java 2D API is true?

A) A Graphics2D object is instantiated to draw Java 2D figures.
B) Class Graphics2D is a subclass of class Graphics.
C) To access Graphics2D capabilities, cast the Graphics reference passed to paintComponent to a Graphics2D reference.
D) All of the above are true.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
13
Class FontMetrics declares methods that can be used to obtain the following font metrics ________.

A) ascent, descent and height
B) ascent, descent and leading
C) height and leading
D) All of the above.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements about the Graphics object is true? A. The Graphics object is an argument to class Component's repaint method.
B) The Graphics object is instantiated by the user.
C) The Graphics object is the argument to a lightweight GUI component's paintComponent method.
D) The Graphics class is abstract.
E) The Graphics object manages a graphics context.

A) A, C, E.
B) C, D, E.
C) A, B, D, E.
D) All are true.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
15
A general path is ________.

A) a set of polylines that do not result in a closed shape
B) a shape constructed from straight lines and complex curves
C) the shape of the curve in a font's characters
D) represented by an object of class GraphicsPath
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
16
The Graphics2D method(s) that determine(s) the color and texture for the shape to display is/are:

A) setStroke
B) setPaint
C) setTexture and setColor
D) setTexturePaint
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following are valid Java statements?
A. Color c = new Color(0, 255, 0);
B. Color c = new Color(0.0f, 1.0f, 0.0f);
C. Color c = new Color(0.0d, 1.0d, 0.0d);
D. setGreen;

A) All of the above.
B) A, B, C.
C) A, B, D.
D) A, B.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
18
Consider the code segment below:
int xValues[] = {100, 150, 200, 100};
Int yValues[] = {30, 130, 30, 30};
G.drawPolyline(xValues, yValues, 4);
What kind of figure does it draw?

A) A rectangle.
B) A triangle.
C) A V with its corner at the top.
D) A square.
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
19
Consider the Java code segment below:
Polygon poly2 = new Polygon();
Poly2.addPoint(100, 30);
Poly2.addPoint(100, 130);
Which of the following will create a polygon that is a square?

A) poly2.addPoint(100, 60); poly2.addPoint(100, 130);
B) poly2.addPoint(200, 130); poly2.addPoint(200, 30);
C) poly2.addPoint(200, 60); poly2.addPoint(200, 130);
D) poly2.addPoint(100, 130); poly2.addPoint(100, 230);
Unlock Deck
Unlock for access to all 19 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 19 flashcards in this deck.