Exam 17: Applets, Images, and Sound
Exam 1: Creating Java Programs68 Questions
Exam 2: Using Data74 Questions
Exam 3: Using Methods, Classes, and Objects68 Questions
Exam 4: More Object Concepts67 Questions
Exam 5: Making Decisions70 Questions
Exam 6: Looping72 Questions
Exam 7: Characters, Strings, and the Stringbuilder73 Questions
Exam 8: Arrays74 Questions
Exam 9: Advanced Array Concepts74 Questions
Exam 10: Introduction to Inheritance70 Questions
Exam 11: Advanced Inheritance Concepts70 Questions
Exam 12: Exception Handling65 Questions
Exam 13: File Input and Output74 Questions
Exam 14: Introduction to Swing Components74 Questions
Exam 15: Advanced Gui Topics69 Questions
Exam 16: Graphics74 Questions
Exam 17: Applets, Images, and Sound72 Questions
Select questions type
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class JCompanyImage extends JApplet
{
Image companyLogo;
final int WIDTH = 287;
final int HEIGHT = 129;
final int FACTOR = 2;
public void init()
{
companyLogo = getImage(getCodeBase(), "CompanyLogo. png");
}
public void paint(Graphics g)
{
super.paint(g);
// Draw image at its natural size
___________________________________
// Draw the image scaled - twice as large
___________________________________
}
}
Using the above code, complete the first shaded line with the statement to draw the image first in its original size in the upper-left corner. In the second shaded line, write the code to redraw the image at twice its original size using the WIDTH, HEIGHT, and FACTOR values.
(Essay)
4.9/5
(35)
There are three attributes typically placed within the <object> tag: code, width, and height. Describe the purpose of the three object tag attributes and their corresponding arguments.
(Essay)
4.9/5
(39)
In order to play sounds more than once, or to stop and start sounds, the sound must be loaded into an AudioClip object. Write the statement to load the AudioClip named myClip with the sound file myTune.au, which is located in the audio folder.
(Essay)
4.8/5
(32)
public void actionPerformed(ActionEvent e)
{
String name = answer.getText();
con.remove(greeting);
con.remove(pressMe);
con.remove(answer);
personalGreeting.setText("Hello, " + name + "! ");
con.add(personalGreeting);
con.setBackground(Color.PINK);
validate();
}
In the actionPerformed() method above, the final statement following the addition of the JLabel is validate(). Explain the validate() method and how it is used with JComponents.
(Essay)
4.7/5
(41)
The applet can be run within a page on the Internet or an intranet, but you do not have to connect to the Internet to run an applet in your browser-you can simply use the browser locally.
(True/False)
4.8/5
(40)
Match each term with the correct statement below.
-Surrounded by angle brackets
(Multiple Choice)
4.9/5
(37)
Match each term with the correct statement below.
-Executes again every time the applet becomes active after it has been inactive
(Multiple Choice)
4.8/5
(35)
The ____ method is used to load an Image into the named Image in the applet.
(Multiple Choice)
4.9/5
(39)
You override the existing empty ____ method only if you want to take some action when a JApplet is no longer visible.
(Multiple Choice)
4.8/5
(29)
Match each term with the correct statement below.
-The first method called in any applet
(Multiple Choice)
4.9/5
(36)
Match each term with the correct statement below.
-Extensible Hypertext Markup Language
(Multiple Choice)
4.9/5
(34)
With an applet, the browser can call ____ different methods automatically at different times.
(Multiple Choice)
4.8/5
(40)
Showing 41 - 60 of 72
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)