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
Why would a JSlider component be ideal when you want the user to enter a number, but you want to make sure that the number is within a range?
This is a key that activates a component just as if the user clicked it with the mouse.a. Mnemonicb. Key activatorc. Tool tipd. Click simulator
Briefly describe each of the following menu system items:a) Menu barb) Menu itemc) Check box menu itemd) Radio button menu iteme) Submenuf) Separator bar
Write code that creates a JSlider component. The component should be horizontally oriented and its range should be 0 through 1000. Labels and tick marks should be displayed. Major tick marks should
What are the standard GUI looks and feels that are available in Java?
To display an open file or save file dialog box, you use this class.a. JFileChooserb. JOpenSaveDialogc. JFileDialogd. JFileOptionPane
What class do you use to create a regular menu item? What do you pass to the class constructor?
To display a dialog box that allows the user to select a color, you use this class.a. JColorb. JColorDialogc. JColorChooserd. JColorOptionPane
What class do you use to create a radio button menu item? What do you pass to the class constructor? How do you cause it to be initially selected?
How do you change the size of a component such as a JLabel after it has been created?
You use this class to create a menu bar.a. MenuBarb. JMenuBarc. JMenud. JBar
How do you create a relationship between radio button menu items so that only one may be selected at a time?
You use this class to create a radio button menu item.a. JMenuItemb. JRadioButtonc. JRadioButtonItemd. JRadioButtonMenuItem
What class do you use to create a check box menu item? What do you pass to the class constructor? How do you cause it to be initially selected?
You use this method to place a menu bar on a JFrame.a. SetJMenuBarb. SetMenuBarc. PlaceMenuBard. SetJMenu
What class do you use to create a menu? What do you pass to the class constructor?
The setPreferredSize method accepts this as its argument(s).a. A Size objectb. Two int valuesc. A Dimension objectd. One int value
What class do you use to create a menu bar?
Components of this class are multi-line text fields.a. JMultiLineTextFieldb. JTextAreac. JTextFieldd. JEditField
This method is inherited from JComponent and changes the appearance of a component’s text.a. SetAppearanceb. SetTextAppearancec. SetFontd. SetText
What type of event do menu items generate when selected by the user?
This method sets the intervals at which major tick marks are displayed on a JSlider component.a. SetMajorTickSpacingb. SetMajorTickIntervalsc. SetTickSpacingd. SetIntervals
True or False: You can use code to change the contents of a read-only text field.
What arguments do you pass to the Dimension class constructor?
True or False: A JList component automatically appears with a line border drawn around it.
What arguments do you pass to the JTextArea constructor?
True or False: In single interval selection mode, the user may select multiple items from a JList component.
How do you retrieve the text that is stored in a JTextArea component?
True or False: With an editable combo box the user may only enter a value that appears in the component’s list.
Does the JTextArea component automatically display scroll bars? If not, how do you accomplish this?
True or False: You can store either text or an image in a JLabel object, but not both.
What is line wrapping? What are the two styles of line wrapping? How do you turn a JTextArea component’s line wrapping on? How do you select a line wrapping style?
True or False: You can store large images as well as small ones in a JLabel component.
What type of argument does a component’s setFont method accept?
True or False: Mnemonics are useful for users who are good with the keyboard.
What are the arguments that you pass to the Font class constructor?
True or False: A JMenuBar object acts as a container for JMenu components.
True or False: A JTextArea component does not automatically display scroll bars.
True or False: By default, a JTextArea component does not perform line wrapping.
How do you cause a Timer object to begin generating action events?
What is the difference between an iterative algorithm and a recursive algorithm?
Write a method that accepts a String as an argument. The method should use recursion to display each individual character in the String.
It is said that a recursive algorithm has more overhead than an iterative algorithm. What does this mean?
Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as
A method is called once from a program’s main method, and then it calls itself four times. The depth of recursion is __________.a. Oneb. Fourc. Fived. Nine
Find the error in the following program: Public class FindTheError{ Public static void main(String[] args) { MyMethod(0); } Public static void myMethod(int
What is a recursive algorithm’s base case? What is the recursive case?
What is a base case?
Write a recursive boolean method named isMember. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in the
This is the part of a problem that can be solved without recursion.a. Base caseb. Solvable casec. Known cased. Iterative case
What is a recursive case?
Write a recursive method that accepts a string as its argument and prints the string in reverse order. Demonstrate the method in a program.
This is the part of a problem that is solved with recursion.a. Base caseb. Iterative casec. Unknown cased. Recursion case
What type of recursive method do you think would be more difficult to debug: one that uses direct recursion or one that uses indirect recursion? Why?
What causes a recursive algorithm to stop calling itself?
Write a method named maxElement, which returns the largest value in an array that is passed as an argument. The method should use recursion to find the largest element. Demonstrate the method in a
This is when a method explicitly calls itself.a. Explicit recursionb. Modal recursionc. Direct recursiond. Indirect recursion
Which repetition approach is less efficient: a loop or a recursive method? Why?
What is direct recursion? What is indirect recursion?
A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I,Ere I saw Elba A man, a plan, a canal, PanamaDesserts, I
This is when method A calls method B, which calls method A.a. Implicit recursionb. Modal recursionc. Direct recursiond. Indirect recursion
Convert the following iterative method to one that uses recursion:Public static void sign(int n){ While (n > 0) { System.out.println("No Parking"); N--; }}
When recursion is used to solve a problem, why must the recursive method call itself to solve a smaller version of the original problem?
Write a method that uses recursion to count the number of times a specific character occurs in an array of characters. Demonstrate the method in a program.
This refers to the actions taken internally by the JVM when a method is called.a. Overheadb. Set upc. Clean upd. Synchronization
Write an iterative version (using a loop instead of recursion) of the factorial method shown in this chapter.
How is a problem usually reduced with a recursive method?
Write a method that uses recursion to raise a number to a power. The method should accept two arguments: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer.
True or False: An iterative algorithm will usually run faster than an equivalent recursive algorithm.
Ackermann’s function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a method ackermann(m,n), which solves Ackermann’s function. Use
Write a method that accepts an integer argument and returns the sum of all the integers from 1 up to the number passed as an argument. For example, if 50 is passed as an argument, the method will
True or False: Some problems can be solved through recursion only.
True or False: It is not necessary to have a base case in all recursive algorithms.
True or False: In the base case, a recursive method calls itself with a smaller version of the original problem.
What is an event listener?
Joe’s Automotive performs the following routine maintenance services: • Oil change—$26.00• Lube job—$18.00• Radiator flush—$30.00• Transmission flush—$80.00•
Write code that stores the image in the file dog.jpg in a label.
What is the difference between an uneditable and an editable combo box? Which of these is a combo box by default?
The Skate Shop sells the skateboard products listed in Table 13-2. Data in Table 13-2.In addition, the Skate Shop sells the following miscellaneous products and services: Grip tape:
A list selection listener must have this method.a. ValueChangedb. SelectionChangedc. ActionPerformedd. ItemSelected
What is a mnemonic? How does the user use it?
How do you retrieve the selected item from a JComboBox component? How do you get the index of the selected item?
Create an application that works like a shopping cart system for a bookstore. In this chapter’s source code folder (available on the book’s companion Web site at www.pearsonhighered. com/gaddis),
This is the JList component’s default selection mode.a. Single selectionb. Single interval selectionc. Multiple selectiond. Multiple interval selection
Describe how you can store both an image and text in a JLabel component.
How do you cause a scroll bar to be displayed with a JList component?
To display a scroll bar with a JList component, you must __________.a. Do nothing; the JList automatically appears with scroll bars if necessaryb. Add the JList component to a JScrollPane componentc.
A university has the following dormitories:Allen Hall: $1,500 per semesterPike Hall: $1,600 per semesterFarthing Hall: $1,200 per semesterUniversity Suites: $1,800 per semesterThe university also
What is the difference between an uneditable combo box and an editable combo box? Which one is a combo box by default?
A JList component generates this type of event when the user selects an item.a. Action eventb. Item eventc. List selection eventd. List change event
Write an application that allows the user to view image files. The application should use either a button or a menu item that displays a file chooser. When the user selects an image file, it should
You want to provide 20 items in a list for the user to select from. Which component would take up less space, a JList or a JComboBox?
Write code that creates a list with the following items: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.
You can use this method to make a text field read-only.a. SetReadOnlyb. SetChangeablec. SetUneditabled. SetEditable
Create an application that allows you to enter the amount of a purchase and then displays the amount of sales tax on that purchase. Use a slider to adjust the tax rate between 0 percent and 10
What selection mode should you select if you want the user to select a single item only in a list?
Give an example of code that creates a read-only text field.
How do you make a text field read-only? In code, how do you store text in a text field?
What is the preferred way of creating a Border object?
What method do you use to set a border around a component?
Showing 100 - 200
of 1252
1
2
3
4
5
6
7
8
9
10
11
12
13