1.  If your applet does not have the init() method, which of the following will happen?
a.  Your program will not compile.
b.  You must have a main method.
c.  Your program will compile, but not execute.
d.  Your program will run just fine since the init() method is defined in the Applet class.
#
2.  The _______ method in the applet is invoked when the user leaves the page that contains the applet.
a.  destroy
b.  start
c.  stop
d.  init
#
3.  To create an audio clip for a file named beep.au in the same directory of the applet, you use __________.
a.  URL url = Class().getResource("beep.au"); AudioClip audioClip = wAudioClip(url);
b.  URL url = Class().getResource("beep.au"); AudioClip audioClip = ateAudioClip(url);
c.  Class metaObject = Class(); URL url = Resource("beep.au"); AudioClip audioClip = wAudioClip(url);
d.  Class metaObject = Class(); URL url = Resource("beep.au"); AudioClip audioClip = ateAudioClip(url);
#
4.  Which of the following statements are true?
a.  Classes are dynamically loaded when needed.
java replace方法b.  A class will be loaded only once in an application or applet.
c.  When a class (e.g., java.lang.Math) is loaded, the JVM creates a meta-object for the class.
d.  Two objects of the same class share the same meta-object.
#
5.  What format of audio files are currently supported?
a.  MIDI
b.  RMF
c.  WAV
d.  AIFF
e.  AU
#
6.  The method that executes immediately after the init() method in an applet is __________.
a.  stop()
b.  destroy()
c.  run()
d.  start()
#
7.  You can add menus into an applet.
a.  true
b.  false
#
8.  To create a URL for an image file located in the same directory with the class, use
a.  Class metaObject = Resource(imageFilenameString);
b.  Object metaObject = Class(); URL url = Resource(imageFilenameString);
c.  URL url = Class().getResource(imageFilenameString);
d.  Class metaObject = Class(); URL url = Resource(imageFilenameString);
#
9.  Which of the following is true?
a.  The Applet class is in javax.swing package.
b.  The JApplet class is in javax.swing package.
c.  JApplet is a subclass of Applet.
d.  Applet is a subclass of JApplet.
#
10.  Suppose you pass parameter named message from HTML to the following applet, analyze the code:
import javax.swing.*;
public class Test extends JApplet {
public Test() {
String message = getParameter("MESSAGE");
add(new JLabel(message));
}
}
a.  The program has a compile error because you cannot invoke getParameter("MESSAGE") from the constructor.
b.  The program has a runtime error because you cannot invoke getParameter("MESSAGE") from the constructor.
c.  The program has a compile error because parameter names are case-sensitive. You should replace MESSAGE with message.
d.  The prog
ram runs fine and displays the label with the message passed from the HTML file.
#
11.  Which of the following statements are true?
a.  A URL object may be returned using the getSource method on a meta object (instance of java.lang.Class).
b.  You can create a URL object for a local file.
c.  A URL object may be created using the new URL(urlString) constructor.
d.  You can create a URL object for any public accessible resource on the Internet.
#
12.  Having a main() method in an applet causes errors.
a.  false
b.  true
#
13.  Java applications and applets both __________.
a.  are executed using the java command
b.  are compiled using the javac command
c.  have a main() method
d.  are executed from the HTML file
#
14.  To repeatedly play an instance of audio clip ac, you use __________.
a.  ac.repeating()
b.  ac.continue()
c.  ac.loop()
d.  ac.repeat()
#
15.  To use an applet in the HTML document, you use __________ in the <applet> tag.
a.  .exe executable file
b.  .class bytecode
c.  .html file
d.  .java source code file
#
16.  You can set a title for an applet using the setTitle() method.
a.  false
b.  true
#
17.  The ImageViewer class was presented in Chapter 17. You can use the method _________ to create an Image from a file "image/us.gif" in the same directory of the this class.
a.  ateImageIcon("image/us.gif", this)
b.  ateImageIcon("image/us.gif", null)
c.  ateImage("image/us.gif", this)
d.  ateImage("image/us.gif", null)
#
18.  You can get audio files only through the Applet class.
a.  true
b.  false
#
19.  An applet is declared by extending _______.
a.  JFrame
b.  JPanel
c.  JApplet
d.  Applet
#
20.  You can place an applet into a frame.
a.  false
b.  true
#
21.  The __________ method is executed when the page becomes inactive.
a.  destroy()
b.  init()
c.  start()
d.  stop()
#
22.  Which of the following statements are true?
a.  Applets are not allowed to run programs on the browser's computer.
b.  Applets are not allowed to read from, or write to, the file system of the computer.
c.  In general, an applet can be converted to an application without loss of functionality.
d.  An application can be converted to an applet as long as it does not violate the security restrictions imposed on applets.
e.  Applets are not allowed to establish connections between the user’s computer and any other computer, except for the server where the applets are stored.
#
23.  The return type of init(), start(), stop(), and destroy() is void.
a.  false
b.  true
#
24.  A main() method is required to run an applet.
a.  false
b.  true
#
25.  If you pass HTML parameters to an applet, you must override the init() method to receive the parameters.
a.  true
b.  false
#
26.  You can launch frames from an applet.
a.  false
b.  true
#
27.  Java ca
n display .gif and .jpg image files.
a.  false
b.  true
#
28.  Which of the following statements are true?
a.  An applet is a GUI component and it can be added to a container.
b.  If an applet has a main method, it can be executed standalone.
c.  When an applet runs from a browser, its init method is not invoked after its no-arg constructor is invoked.
d.  When an applet runs from a browser, its main method (if exists) is not invoked by the browser.
#
29.  A main() method is required to run an application.
a.  false
b.  true
#
30.  You must always override the init() method in the applet.
a.  true
b.  false
#
31.  Analyze the following code.
import javax.swing.*;
public class Test extends JApplet {
public void init() {
add(new JLabel("OK"));
}
public static void main(String[] args) {
Test applet = new Test();
}
}
a.  All of the above.
b.  When you run the applet standalone from the main method, the OK label is not displayed because the init() was not invoked.
c.  When you run the applet standalone from the main method, nothing is displayed.
d.  When you run the applet from a browser, the OK label is displayed.
#
32.  To get an ImageIcon for the a specified URL, you use __________.
a.  new ImageIcon(url);
b.  getImage(url)
c.  Image()
d.  ateImage()
e.  createImage(url)
#
33.  To specify an HTML parameter named message with the value "Welcome to Java", you write the following HTML tag:
a.  None of the above.
b.  <param name=message, value=Welcome to Java>
c.  <param name=message value="Welcome to Java">
d.  <param name=message, value="Welcome to Java">
#
34.  The Applet's getParameter method can be invoked from the applet's default constructor.
a.  false
b.  true
#
35.  What format of image files are currently supported?
a.  JPEG
b.  GIF
c.  PNG
d.  BMP
#
36.  When you run an applet, which of the following is invoked first?
a.  The stop method. 
b.  The destroy method.
c.  The start method.
d.  The init method.
e.      The applet's default constructor.
#
37.  The HTML tags are enclosed within __________.
a.  curly braces
b.  angle brackets
c.  square brackets
d.  parentheses
#
38.  An applet must _______.
a.  override the init() method
b.  contain a no-arg constructor explicitly or implicitly
c.  contain a main method
d.  override the start() method
#
39.  To draw the image im to fill in the whole viewing area, you use __________.
a.  drawImage(im)
b.  drawImage(im, 0, 0, this)
c.  drawImage(im, 0, 0, getSize().width, getSize().height)
d.  drawImage(im, 10, 10)
#
40.  If you try to retrieve an HTML parameter that is not defined in the HTML page, what will happen?
a.  You will get a runtime error.
b.  You will get a compile error.
c.  Your program will run with an empty string in the parameter's value.
d.  Your program will run with the parameter's v
alue null.
#
41.  To retrieve an HTML parameter named message, you write the following code in the init() method:
a.  String s = getParameter("Message");
b.  String s = getParameter("MESSAGE");
c.  String s = Parameter("message");
d.  String s = getParameter("message");
#
42.  When you run the following applet from a browser, what is displayed:
import javax.swing.*;
public class Test extends JApplet {
public Test() {
System.out.println("Default constructor is invoked");
}
public void init() {
System.out.println("Init method is invoked");
}
}
a.  Default constructor is invoked, then Init method is invoked
b.  Init method is invoked
c.  Init method is invoked, then Default constructor is invoked
d.  Default constructor is invoked
#
43.  The default layout of the contentPane of a JApplet is __________.
a.  GridLayout
b.  None
c.  FlowLayout
d.  BorderLayout
#
44.  The init(), start(), stop(), and destroy() methods have no arguments.
a.  false
b.  true
#
45.  An applet may contain _______.
a.  a main method
b.  a no-arg constructor plus other overloaded constructors
c.  an instance method
d.  a static method
#
46.  You can write an applet to run both as an applet and as an application.
a.  false
b.  true
#
47.  The ImageViewer class was presented in Chapter 17. Which of the following statements are true?
a.  You can specify where an image is displayed in an ImageViewer.
b.  You can specify whether an image can be stretched in an ImageViewer.
c.  You can display an image in an ImageViewer.
d.  ImageViewer is a subclass of JPanel.
#
48.
Which of the following is true?
a.  You must always provide a main method for an applet.
b.  You must always provide a no-arg constructor for an applet.
c.  Any applet must be an instance of java.awt.Applet.
d.  You must always override the init method in an applet.
#
49.  An applet must have a no-arg constructor implicitly or explicitly.
a.  false
b.  true
#
50.  To obtain an instance of Image from an ImageIcon, use
a.  Image image = Image();
b.  Image image = Image();
c.  Image image = ateImage();
d.  Image image = ateImage();
#
51.
Applets must be embedded in an HTML page.
a.  true
b.  false
#
52.  You can pass HTML parameters to an applet.
a.  false
b.  true
#
53.  You can view an applet using _______.
a.  a Web browser
b.  an applet viewer
c.  the java command
#
54.  Java only accepts .au format audio files.
a.  true
b.  false

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。