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
How do you determine in code whether a check box is selected?
How do you determine in code whether a radio button is selected?
What type of event does a check box generate when the user clicks on it?
What type of event does a radio button generate when the user clicks on it?
Do you normally add radio buttons, check boxes, or both to a ButtonGroup object?
True or False: You can write a class that extends the JPanel class.
What is the purpose of a ButtonGroup object?
True or False: A mutually exclusive relationship is automatically created among all JRadioButton components in the same container.
You want the user to be able to select any number of items from a group of items. Which type of component would you use for the items, radio buttons or check boxes?
True or False: You normally add JCheckBox components to a ButtonGroup object.
You want the user to be able to select only one item from a group of items. Which type of component would you use for the items, radio buttons or check boxes?
True or False: A component placed in a GridLayout manager’s cell will not be resized to fill up any extra space in the cell.
What is the default layout manager for a JFrame object’s content pane? For a JPanel object?
True or False: You can place a panel inside a region governed by a BorderLayout manager.
How can you cause a content pane to be automatically sized to accommodate the components contained within it?
True or False: You can place multiple components inside a container governed by a FlowLayout manager.
How do you prevent the BorderLayout manager from resizing a component that has been placed in its region?
True or False: You can place multiple components inside a BorderLayout region.
How many components can you have at one time in a BorderLayout region? In a GridLayout cell?
True or False: You can place multiple components inside a GridLayout cell.
Which layout manager arranges components in rows and columns?
True or False: A panel cannot be displayed by itself.
Which layout manager arranges components in a row, from left to right, in the order they were added to the container?
You use this class to create Border objects.a. BorderFactoryb. BorderMakerc. BorderCreatord. BorderSource
Which layout manager divides a container into regions known as north, south, east, west, and center?
Adding radio button components to this type of object creates a mutually exclusive relationship between them.a. MutualExcludeb. RadioGroupc. LogicalGroupd. ButtonGroup
How do you add a layout manager to a container?
Write a GUI application that calculates a car’s gas mileage. The application should let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full
This is the default alignment of a FlowLayout manager.a. Leftb. Centerc. Rightd. No alignment
How do you change the background color of a component? How do you change the color of text displayed by a label or a button?
Components in this/these regions of a BorderLayout manager are resized both horizontally and vertically so they fill up the entire region.a. North and southb. East and westc. Center onlyd. North,
Look at the following list of Latin words and their meanings. Write a GUI application that translates the Latin words to English. The window should have three buttons, one for each Latin word.
How do you register an event listener with a JButton component?
Write code that creates three radio buttons with the text “Option 1”, “Option 2”, and “Option 3”. The radio button that displays the text “Option 1” should be initially selected. Make
Components in this/these regions of a BorderLayout manager are resized vertically so they fill up the entire region.a. North and southb. East and westc. Center onlyd. North, south, east, and west
A long-distance provider charges the following rates for telephone calls: Create a GUI application that allows the user to select a rate category (from a set of radio buttons), and enter the
If you are writing an event listener class for a JButton component, what interface must the class implement? What method must the class have? When is this method executed?
Assume that the variable panel references a JPanel object that uses a BorderLayout manager. In addition, the variable button references a JButton object. Write code that adds the button object to the
Components in this/these regions of a BorderLayout manager are resized horizontally so they fill up the entire region.a. North and southb. East and westc. Center onlyd. North, south, east, and west
If a container is governed by a BorderLayout manager and you add a component to it, but you do not pass the second argument specifying the region, this is the region in which the component will be
This is the default layout manager for a JFrame object’s content pane.a. BorderLayoutb. GridLayoutc. FlowLayoutd. None
What is a content pane?
Create a GUI application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the
How can you create a specialized panel component that can be used to hold other components and their related code?
The variable myButton references a JButton object. Write the code to set the object’s background color to white and foreground color to red.
This is a JPanel object’s default layout manager.a. BorderLayoutb. GridLayoutc. FlowLayoutd. None
How do you display a frame on the screen?
In what type of situation would you present a group of items to the user with radio buttons? With check boxes?
The variable myWindow references a JFrame object. Write a statement that displays the object’s window on the screen.
This is the part of a JFrame object that holds the components that have been added to the JFrame object.a. Content paneb. Viewing areac. Component arrayd. Object collection
How do you set a frame’s size?
Why is it sometimes necessary to place a component inside a panel and then place the panel inside a container governed by a BorderLayout manager?
The variable myWindow references a JFrame object. Write a statement that causes the application to end when the user clicks on the JFrame object’s close button.
The following is an inner class that will be registered as an action listener for a JButton component: Private class ButtonListener implements ActionListener{ Public void
With Swing, you use this class to create a frame.a. Frameb. SwingFramec. JFramed. JavaFrame
What is a frame? How do you create a frame with Swing?
Create a GUI application where the user enters the wholesale cost of an item and its markup percentage into text fields. (For example, if an item’s wholesale cost is $5 and its markup percentage is
If you do not change the default close operation, what happens when the user clicks on the close button on a JFrame object?
The following statement is in a class that uses Swing components: Import java.swing.*;
What must you do to a class in order to serialize objects of that class?
True or False: The throws clause causes an exception to be thrown.
What are the two modes that a random access file may be opened in? Explain the difference between them.
True or False: When in the same try statement you are handling multiple exceptions and some of the exceptions are related to each other through inheritance, you should handle the more general
What class do you use to work with random access files?
True or False: Not including polymorphic references, a try statement may have only one catch clause for each specific type of exception.
What is the difference between sequential and random access?
True or False: When an exception is thrown, the JVM searches the try statement’s catch clauses from top to bottom and passes control of the program to the first catch clause with a parameter that
What classes do you use to write output to a binary file? What classes do you use to read from a binary file?
True or False: You cannot have more than one catch clause per try statement.
What is the difference between a text file and a binary file?
True or False: IOException serves as a superclass for exceptions that are related to programming errors, such as an out-of-bounds array subscript.
If you are writing a custom exception class, how can you make sure it is checked? How can you make sure it is unchecked?
True or False: When an exception is thrown by code inside a try block, all of the statements in the try block are always executed.
If a method has a throw statement, does it always have to have a throws clause in its header? Why or why not?
True or False: You are not required to catch exceptions that inherit from the RuntimeException class.
What is the difference between the throw statement and the throws clause?
This is the process of converting an object to a series of bytes that represent the object’s data.a. Serializationb. Deserializationc. Dynamic conversiond. Casting
What is the purpose of the argument that is passed to an exception object’s constructor? What happens if you do not pass an argument to the constructor?
You use this statement to throw an exception manually.a. Tryb. Generatec. Throwd. System.exit(0)
What does the throw statement do?
This informs the compiler of the exceptions that could get thrown from a method.a. Throws clauseb. Parameter listc. Catch claused. Method return type
When are you required to have a throws clause in a method header?
All exceptions that do not inherit from the Error class or the RuntimeException class are __________.a. Unrecoverable exceptionsb. Unchecked exceptionsc. Recoverable exceptionsd. Checked exceptions
What are the differences between a checked and an unchecked exception?
What happens when you serialize an object? What happens when you deserialize an object?
These are exceptions that inherit from the Error class or the RuntimeException class.a. Unrecoverable exceptionsb. Unchecked exceptionsc. Recoverable exceptionsd. Checked exceptions
A program’s main method calls method A, which calls method B. None of these methods performs any exception handling. The code in method B throws an exception. Describe what happens.
What is the difference between a sequential access file and a random access file?
Assume that the reference variable r refers to a serializable object. Write code that serializes the object to the file ObjectData.dat.
This method may be called from any exception object, and it shows the chain of methods that were called when the exception was thrown.a. PrintInvocationListb. PrintCallStackc. PrintStackTraced.
What is the call stack? What is a stack trace?
What is the difference between a text file and a binary file?
Write a statement that opens the file Customers.dat as a random access file for both reading and writing.
This is an internal list of all the methods that are currently executing.a. Invocation listb. Call stackc. Call listd. List trace
When does the code in a finally block execute?
What is the difference between the throw statement and the throws clause?
Write a statement that creates an object that can be used to write binary data to the file Configuration.dat.
This is one or more statements that are always executed after the try block has executed and after any catch blocks have executed if an exception was thrown.a. Try blockb. Catch blockc. Finally
If multiple exceptions can be thrown by code in a try block, how does the JVM know which catch clause it should pass the control of the program to?
What is the difference between a checked exception and an unchecked exception?
Showing 200 - 300
of 1252
1
2
3
4
5
6
7
8
9
10
11
12
13