Lab 6
- Applets & Applications
Pre
Test
1. A Java applet can be run in the same way as a Java application.
Answer: False
2. Java Applets are standalone.
Answer: False
3. If you include an applet twice in one page, the browser loads the class file once and creates two instances of the class.
Answer: True
4. When you run
an application with the Java interpreter, you specify the name of the class
that you want to run. It is mandatory for the main method to be defined within that class.
True or false?
Answer: True
5. Which of the following statements is correct?
I. A Java applet contains a single main method.
II. A Java applet may contain only one class.
III. A Java applet must use an applet viewer to render itself.
a. I
b. I, II
c. I, II, & III
d. None of the statements are correct.
Answer: D
6. When a Java-capable browser encounters an <APPLET> tag, it
I. Loads the Applet subclass onto the computer the browser is executing on.
II. Creates an instance of the Applet subclass.
III. Compiles the Java source code to create the .class file.
IV. Reserves onscreen space for the applet.
a. I, IV
b. I, II, IV
c. II, III, IV
d. None of the statements are correct.
Answer: B
Comprehension:
7. Which of the following statements is true?
I. A given class can have only one main method.
II. A given class can have only objects of its own type.
III. In a Java program with multiple classes, each class must import all of the other classes.
IV. In a Java program, there can be only one class.
a. I
b. I, II, & IV
c. I, II, & III
d. None of the statements are true.
Answer: A
Answer: B
8. Applications that need to use packages cannot be written without the ‘import’ statement.
Answer: A
9. If the source code for a class does not have a package statement at the top to explicitly declare the package the class is in, then the class
Answer: B
10. Which of the following statements is true?
I. A Java applet cannot ordinarily read or write files on the computer that it is executing on.
II. A Java applet cannot make network connections except to the host that it came from.
III. A Java applet can invoke the public methods of other Applets on the same page.
Answer: A