Exercise/Homework EH44

Total Page:16

File Type:pdf, Size:1020Kb

Exercise/Homework EH44

CPSC426 Jave EH44 1

Exercise/Homework EH44

Q1: The browser that executes an applet is generically known as the ______. a.applet storage. b.applet container. c.applet viewer. d.applet executer.

ANS:

Q2: 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:

Q3: Every Java applet or application is composed of at least one: a.public method b.data member c.public class declaration d.imported class

ANS:

Q4: When an applet container loads an applet, the container calls three of the applet’s methods. In sequence, these three methods are: a.start, init, stop. b.start, init, paint. c.init, start, stop. d.init, start, paint.

ANS:

Q5: 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:

Q6: 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: CPSC426 Jave EH44 2

Q7: 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 tag. b.Omitting the ending 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:

Q8: Which method is called once by the applet container when an applet is loaded for execution. a.start b.init c.paint d.load

ANS:

Q9: Which method is called by the applet container when the applet is being removed from memory. a.stop b.remove c.destroy d.end

ANS:

Q10: 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:

Q11: 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:

Q12: The Java platform uses the ______to prevent code that is downloaded to your local computer from accessing local system resources, such as files. a.blackbox security model. b.sandbox security model. c.whitebox security model. d.download security model.

ANS: CPSC426 Jave EH44 3

Q13: Write an applet that draws rectangles of different sizes and locations.

ANS: CPSC426 Jave EH44 4

Q14: Write an applet that allows the user to input values for the arguments required by method drawRect, then draws a rectangle using the four input values.

Recommended publications