All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
starting out with java from control structures
Questions and Answers of
Starting Out With Java From Control Structures
The numeric wrapper classes’ “parse” methods all throw an exception of this type.a. ParseExceptionb. NumberFormatExceptionc. IOExceptiond. BadNumberException
How do you retrieve an error message from an exception?
When are you required to have a throws clause in a method header?
The method getValueFromFile is public and returns an int. It accepts no arguments. The method is capable of throwing an IOException and a FileNotFoundException. Write the header for this method.
This method can be used to retrieve the error message from an exception object.a. ErrorMessageb. ErrorStringc. GetErrord. GetMessage
File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code,
After the catch block has handled the exception, where does program execution resume?
What types of objects can be thrown?
You can think of this code as being “protected” because the application will not halt if it throws an exception.a. Try blockb. Catch blockc. Finally blockd. Protected block
Design a class that has a static method named writeArray. The method should take two arguments: the name of a file and a reference to an int array. The file should be opened as a binary file, the
What is the difference between a try block and a catch block?
When multiple exceptions are caught in the same try statement and some of them are related through inheritance, does the order in which they are listed matter?
Write an exception class that can be thrown when a negative number is passed to a method.
FileNotFoundException inherits from __________.a. Errorb. IOExceptionc. JavaExceptiond. FileException
What is the difference between exceptions that inherit from the Error class and exceptions that inherit from the Exception class?
Where does execution resume after an exception has been thrown and caught?
Write a statement that throws an IllegalArgumentException with the error message “Argument cannot be negative”.
All exception classes inherit from this class.a. Errorb. RuntimeExceptionc. JavaExceptiond. Throwable
Other than the Object class, what is the superclass for all exceptions?
What is the purpose of a finally clause?
Write a method that searches a numeric array for a specified value. The method should return the subscript of the element containing the value if it is found in the array. If the value is not found,
If your code does not handle an exception when it is thrown, it is dealt with by this.a. Default exception handlerb. The operating systemc. System debuggerd. Default exception generator
If an exception is thrown and the program does not handle it, what happens?
What happens when an exception is thrown, but the try statement does not have a catch clause that is capable of catching it?
This is a section of code that gracefully responds to exceptions.a. Exception generatorb. Exception manipulatorc. Exception handlerd. Exception monitor
What does it mean to “throw” an exception?
What does it mean to catch an exception?
Look at the following program and tell what it will output when run: Public class ExceptionTest{ Public static void main(String[] args) { Int number; String
When an exception is generated, it is said to have been __________.a. Builtb. Thrownc. Caughtd. Killed
Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test
Briefly describe what an exception is.
What is meant when it is said that an exception is thrown?
True or False: A JSlider component generates an action event when the slider knob is moved.
True or False: By default, a JSlider component displays labels and tick marks.
True or False: When labels are displayed on a JSlider component, they are displayed on the major tick marks.
Write the text and HTML tags necessary to display “My Home Page” as a level one header, centered in the browser window.
When a user accesses a Web page on a remote server with his or her browser, and that Web page has an applet associated with it, is the applet executed by the server or by the user’s system?
Write an applet that draws the house shown on the left in Figure 14-33. When the user clicks on the door or windows, they should close. The figure on the right shows the house with its door and
Write an applet that initially displays the word “Hello” in the center of a window. The word should follow the mouse cursor when it is moved inside the window.
How is an applet that is associated with a Web page executed on a user’s system?
This section of an HTML document contains all of the tags and text that produce output in the browser window.a. Headb. Contentc. Bodyd. Output
You have written an applet and saved the source code in a file named MyApplet.java. Write the HTML tag needed to execute the applet in an area that is 300 pixels wide by 200 pixels high. Assume that
List at least three security restrictions imposed on applets.
Look at the following GUI application class and indicate by line number the changes that should be made to convert this to an applet using Swing: 1 public class SimpleWindow extends JFrame 2
Why do applets run in a restricted environment?
Write an applet that displays a drawing of two eyes in the center of its window. When the mouse cursor is not inside the window, the eyes should look ahead. When the mouse cursor is inside the
You place the tag in this section of an HTML document.a. Headb. Contentc. Bodyd. Output
Everything that appears between these tags in an HTML document is the content of the Web page. a. b. c. d.
Why are applets sometimes necessary in Web page development?
What tag marks the beginning and end of an HTML document?
To create a level one header you use this tag. a. b. c. d.
Assume that g references a Graphics object. Write code that performs the following:a. Draws an outline of a rectangle that is 100 pixels wide by 200 pixels high, with its upper-left corner at
Why isn’t it necessary to call the setVisible method to display an applet?
Write an applet that displays a thermometer. The user should be able to control the temperature with a slider component. When the user moves the slider, the thermometer should show the corresponding
What tag marks the beginning and end of an HTML document’s head section?
Rewrite the following mouse motion listener so it uses an adapter class: Private class MyMouseMotionListener implements MouseMotionListener{ Public void mouseDragged(MouseEvent
Why would you ever need to use the older AWT library instead of Swing to develop an applet?
Write an applet that lets the user click on six points. After the sixth point is clicked, the applet should draw a polygon with a vertex at each point the user clicked.
What statement would you use in an HTML document to display the text “My Web Page” in the browser’s title bar? What section of the HTML document would this statement be written in?
When using Swing to write an applet, you extend the applet’s class from this class.a. Appletb. JAppletc. JFramed. JAppletFrame
Assume that a class has an inner class named MyTimerListener that can be used to handle the events generated by a Timer object. Write code that creates a Timer object with a time delay of one half
A panel is 600 pixels wide by 400 pixels high. What are the X and Y coordinates of the pixel in the upper-left corner? The upper-right corner? The lower-left corner? The lower-right corner? The
Write an applet that displays a 4 × 4 grid. When the user clicks on a square in the grid, the applet should draw a filled circle in it. If the square already has a circle, clicking on it should
What tag marks the beginning and end of an HTML document’s body section?
When using AWT to write an applet, you extend the applet’s class from this class. a. Appletb. JAppletc. JFramed. JAppletFrame
When is a component’s paint or paintComponent method called?
What statement would you write in an HTML document to display the text “Student Roster” as a level one header?
This applet method is invoked instead of a constructor.a. StartUpb. BeginAppletc. Invoked. Init
What is an adapter class? How does it make some programming tasks more convenient? Under what circumstances does the Java API provide an adapter class?
Write an applet that simulates a stopwatch. It should have a Start button and a Stop button. When the Start button is clicked the applet should count the seconds that pass. When the Stop button is
What statement would you write in an HTML document to display the text “My Resume” in bold and centered on the page?
The Sun JDK comes with this program, which loads and executes an applet without the need for a Web browser.a. Applettestb. Appletloadc. Appletviewerd. Viewapplet
Under what circumstances would you want to use an AudioClip object to play a sound file, rather than the Applet class’s play method?
Write an application that displays a slideshow of images, one after the other, with a time delay between each image. The user should be able to select up to 10 images for the slide show and specify
What statement would you write in an HTML document to display the text “Hello World” in bold and italic?
A class that inherits from Applet or Frame does not have one of these. a. An add methodb. An init methodc. A content paned. A layout manager
What tag causes a line break? What tag causes a paragraph break? What tag displays a horizontal rule?
What location on a component usually has the coordinates (0,0)?a. Upper-right cornerb. Upper-left cornerc. Centerd. Lower-right corner
In a class that extends JApplet or JFrame you override this method to get a reference to the Graphics object.a. Paintb. PaintComponentc. GetGraphicsd. Graphics
Suppose you wanted to display the text “Click Here” as a link to the Web site http://java.sun.com. What statement would you write to create the text?
Instead of JFrame, an applet class is extended from what class?
In a class that extends JPanel you override this method to get a reference to the Graphics object.a. Paintb. PaintComponentc. GetGraphicsd. Graphics
Instead of a constructor, an applet class uses what method?
The drawLine method is a member of this class.a. JAppletb. Appletc. JFramed. Graphics
Why is there no need for a static main method to create an instance of an applet class?
To force the paint method to be called to update a component’s display, you __________.a. Call the paint methodb. Call the repaint methodc. Call the paintAgain methodd. Do nothing; you cannot force
Suppose the file MyApplet.java contains the Java source code for an applet. What tag would you write in an HTML document to run the applet in an area that is 400 pixels wide by 200 pixels high?
A class that implements this interface can handle mouse dragged events.a. MouseListenerb. ActionListenerc. MouseMotionListenerd. MouseDragListener
To create an applet using AWT, what class do you inherit your applet class from?
A class that implements this interface can handle mouse click events.a. MouseListenerb. ActionListenerc. MouseMotionListenerd. MouseDragListener
In Swing, if an object’s class extends JFrame or JApplet, you add components to its content pane. How do you add components to an object if its class extends Frame or Applet?
This MouseEvent method returns the X coordinate of the mouse cursor at the moment the mouse event is generated. a. GetXCoordb. GetMouseXc. GetPositiond. GetX
In an AWT component, or a class that extends JApplet or JFrame, if you want to get a reference to the Graphics object, do you override the paint or paintComponent method?
If a class implements a standard API interface that specifies more than one method but does not need many of the methods, this should be used instead of the interface.a. Your own detailed versions of
In a JPanel object, do you override the paint or paintComponent method to get a reference to the Graphics object?
A Timer object’s time delay between events is specified in this unit of time.a. Secondsb. Microsecondsc. Millisecondsd. Minutes
When are the paint and paintComponent method called?
A Timer object generates this type of event.a. Action eventsb. Timer eventsc. Item eventsd. Interval events
In the paint or paintComponent method, what should be done before anything else?
The following Applet class method returns a URL object with the location of the HTML file that invoked the applet.a. GetHTMLlocationb. GetDocumentBasec. GetAppletBased. GetCodeBase
Showing 300 - 400
of 1252
1
2
3
4
5
6
7
8
9
10
11
12
13