Java How To Program, 5/e Test Item File 1 of 2
Java How To Program, 5/e Test Item File 1 of 2
Java How To Program, 5/e Test Item File 1 of 2
Chapter 3
Section 3.2
3.2 Q1: You can start an applet initially by using the appletviewer. The applet can be restarted by using which
of the following Applet menu items?
a.save.
b.quit.
c.tag.
d.reload.
ANS: d. reload.
Section 3.3
3.3 Q4: To draw on an applet, the programmer must access the _____ object in the applet's paint method.
a.drawstring
b.drawLine
c.Graphics
d.Pixel
ANS: c. Graphics
3.3 Q5: When an applet container encounters an HTML file that specifies an applet to execute, the applet container
automatically loads ________ of the applet from the same directory as that of the HTML file.
a.the .java file
b.the .class file
c.the main line
d.the .htm file
ANS: b. the .class file
3.3 Q6: Which of the following will not produce an error when trying to load and run a program with the
appletviewer?
a.Placing additional characters, such as commas, between the components in the <applet> tag.
b.Omitting the ending </applet> tag.
c.Creating an applet that is less than 640 pixels by 480 pixels.
d.Running the appletviewer with a file name that does not end with .html or .htm .
ANS: c. Creating an applet that is less than 640 pixels by 480 pixels.
Section 3.4
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 2 of 2
3.4 Q1: Which method should be used to draw a line of text on an applet?
a.Graphics method drawText.
b.Text method drawLine.
c.Graphics method drawLine.
d.Graphics method drawString.
ANS: d. Graphics method drawString.
3.4 Q2: To draw a single black line from (0, 15) to (20, 25), call the method _________ in the paint method.
a.g.drawLine( 0, 15, 20, 25 );
b.g.drawString( "black", 0, 15 );
c.g.drawLine( 0, 15, 20, 10 );
d.g.drawLine( 15, 0, 25, 20 );
ANS: a. g.drawLine( 0, 15, 20, 25 );
Section 3.5
3.5 Q1: A floating point variable declared as primitive type double has ___ significant digits.
a.12
b.16
c.32
d.15
ANS: d. 15
3.5 Q2: Which of the following import statements will import the Graphics class?
a.import java.awt.Graphics;
b.import java.awt.*
c.import java.swing.Graphics;
d.import java.awt.g;
ANS: a. import java.awt.Graphics; [Note: answer b is not correct because the semicolon (;) is missing.]
class SampleClass {
int a;
int b;
AnotherClass q;
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.