Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis Test Bankpdf download
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis Test Bankpdf download
https://testbankdeal.com/product/java-foundations-introduction-
to-program-design-and-data-structures-4th-edition-lewis-test-
bank/
https://testbankdeal.com/product/java-software-solutions-foundations-
of-program-design-7th-edition-lewis-test-bank/
https://testbankdeal.com/product/java-software-solutions-foundations-
of-program-design-7th-edition-lewis-solutions-manual/
https://testbankdeal.com/product/c-programming-program-design-
including-data-structures-6th-edition-malik-test-bank/
https://testbankdeal.com/product/human-resource-management-10th-
edition-byars-test-bank/
Guide To SQL 8th Edition Pratt Test Bank
https://testbankdeal.com/product/guide-to-sql-8th-edition-pratt-test-
bank/
https://testbankdeal.com/product/further-mathematics-for-economic-
analysis-2nd-edition-sydsaeter-solutions-manual/
https://testbankdeal.com/product/statistics-learning-from-data-1st-
edition-roxy-peck-test-bank/
https://testbankdeal.com/product/anatomy-and-physiology-9th-edition-
patton-test-bank/
https://testbankdeal.com/product/nursing-today-transition-and-
trends-7th-edition-zerwekh-test-bank/
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
1) The default layout manager used by the JPanel class is the _______________________ layout.
a) flow
b) border
c) box
d) grid
e) gridBag
Answer: a
Explanation: The flow layout is the default layout manager used by JPanel objects.
2) A(n) ___________________ is an object that defines a screen element used to display information or allow the user to
interact with a program in a certain way.
a) GUI
b) component
c) event
d) listener
e) AWT
Answer: b
Explanation: A component is an object that defines a screen element used to display information or allow the user to
interact with a program in a certain way. A GUI is a graphical user interface. An event is an object that represents some
occurrence in which we may be interested. A listener is an object that waits for an event to occur and responds in some way
when it does. AWT stands for the Abstract Windowing Toolkit, which is a package that contains classes related to Java GUIs.
3) A(n) ____________________ is an object that waits for an event to occur and responds in some way when it does.
a) GUI
b) component
c) listener
d) frame
e) panel
Answer: c
Explanation: A listener is an object that waits for an event to occur and responds in some way when it does. A
component is an object that defines a screen element used to display information or allow the user to interact with a program in a
certain way. A GUI is a graphical user interface. A frame is a container that is used to display GUI-based Java applications. A
panel is also a container, but unlike a frame it cannot be displayed on its own.
1
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
4) A GUI is being designed that will detect and respond to a mouse event. How many methods must appear in the listener
object for the event?
a) 1
b) 2
c) 3
d) 4
e) 5
Answer: e
Explanation: A listener for a mouse event implements the MouseListener interface. The MouseListener
interface contains specifications for five methods to respond to different types of mouse events that can be detected. Each of
these methods must appear in the listener and have a body. If a method is not needed, its body can be an empty set of { }.
5) A container is governed by a(n) __________________, which determines exactly how the components added to the panel
will be displayed.
a) event
b) content pane
c) JFrame object
d) JPanel object
e) layout manager
Answer: e
Explanation: The layout manager determines exactly how the components added to the panel will be displayed. A
content pane's frame is where all visible elements of a Java interface are displayed. The JFrame and JPanel objects are part of
the AWT package. An event is an object that represents some occurrence in which we may be interested.
6) Which of the following components allows the user to enter typed input from the keyboard.
a) check boxes
b) radio buttons
c) sliders
d) combo boxes
e) none of the above
Answer: e
Explanation: None of the listed components allow typed input. A text field allows typed input from the user.
7) Which of the following components allows the user to select one of several options from a "drop down" menu?
a) check boxes
b) radio buttons
c) sliders
d) combo boxes
e) none of the above
Answer: d
Explanation: Combo boxes allow the user to select one of several options from a "drop down" menu.
2
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
8) Which of the following layout managers organize the components from left to right, starting new rows as necessary?
a) Border Layout
b) Box Layout
c) Card Layout
d) Flow Layout
e) Grid Layout
Answer: d
Explanation: The flow layout organizes components from left to right, starting new rows as necessary. A border
layout organizes components into five areas: north, south, east, west, and center. The box layout organizes components into a
single row or column. The card layout organizes components into one area such that only one is visible at any time. A grid
layout organizes components into a grid of rows and columns.
9) Which of the following event descriptions best describes the mouse entered event?
Answer: c
Explanation: The mouse entered event is triggered when the mouse pointer is moved onto a component. Choice a best
describes a mouse pressed event. Choice b best describes a mouse clicked event. Choice d best describes a mouse released event.
Choice e best describes a mouse dragged event.
10) A(n) _______________________ is a graphical window that pops up on top of any currently active window so that the
user can interact with it.
a) component
b) dialog box
c) event
d) listener
e) none of the above
Answer: b
Explanation: The sentence describes a dialog box. Events and listeners are not windows. Components are graphical
elements that appear in windows, but they are not windows.
Answer: e
Explanation: All of the choices are fundamental ideas of good GUI design.
3
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
a) it starts when a GUI component is first initialized, and ends when it is destroyed
b) it generates action events at regular intervals
c) every object has a timer, and it is implicitly activated in the constructor of the object
d) it determines the amount of time it takes to execute a method
e) a timer cannot be considered a GUI component
Answer: b
Explanation: Choice b is the best description of a timer component. None of the other choices are true statements.
13) Which of the following border styles can make a component appear raised or lowered from the rest of the components?
a) line border
b) etched border
c) bevel border
d) titled border
e) matte border
Answer: c
Explanation: A bevel border can be used to add depth to a component and give it a 3-D appearance.
14) Which of the following represents a dialog box that allows the user to select a file from a disk or other storage medium?
a) color chooser
b) disk chooser
c) tool tip chooser
d) file chooser
e) none of the above
Answer: d
Explanation: A file chooser is a dialog box that allows the user to select a file. A color chooser allows the user to select
a color. There are no dialog boxes in the AWT that represent a tool tip chooser or a disk chooser.
15) Which of the following classes play a role in altering a visual aspect of a component?
a) ColorChooser
b) ToolTip
c) BorderFactory
d) ColorCreator
e) none of the above
Answer: c
Explanation: The BorderFactory class can be used to create borders, and when used with the setBorder()
method, the borders of components can be changed. The other options are not classes that are included with the AWT.
4
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
True/False Questions:
1) A panel is displayed as a separate window, but a frame can only be displayed as part of another container.
Answer: False
Explanation: A frame is displayed as a separate window, but a panel can only be displayed as part of another container.
4) A dialog box allows the user to select one of several options from a "drop down" menu.
Answer: False
Explanation: A combo box allows the user to select one of several options from a "drop down" menu. A dialog box is
a pop-up window that allows for user interaction.
5) The grid layout organizes components into a grid of rows and columns, and also allows components to span more than one
cell.
Answer: False
Explanation: Both the grid and the GridBag layouts organized components into a grid of rows and columns. Only a
GridBag layout allows components to span more than one cell.
9) When designing a GUI, the ability of the user is not an important consideration. A GUI should be designed with the lowest
common denominator in mind.
Answer: False
Explanation: It is important to design GUIs that are flexible and that support both skilled and unskilled users.
10) A mnemonic is a short line of text that will appear when the cursor is rested momentarily on top of the component.
Answer: False
Explanation: A mnemonic is a character that allows the user to push a button or make a menu choice using the
keyboard in addition to the mouse. A tool-top is a short line of text that will appear when the cursor is rested momentarily on
top of the component.
5
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
Answer: A check box sets a boolean condition to true or false. Therefore if there are multiple items listed with check
boxes by each, any or all of them can be checked at the same time. A radio button represents a set of mutually exclusive
options. This means that at any given time, only one option can be selected.
Answer: A combo box is a component that allows the user to select one of several options from a "drop down" menu.
A dialog box is a graphical window that pops up on top of any currently active windows so that the user can interact with it.
Answer: A confirm dialog box presents the user with a simple yes-or-no question. A file chooser is a dialog box that
presents the user with a file navigator that can be used to select a file. A color chooser is a dialog box that allows the user to
select an RGB color.
4) What method in what interface is used in a GUI application to detect that a user typed the letter 'Y'?
Answer: The keyPressed() method in the KeyListener interface can be used to determine which key was
typed.
5) Write a keyPressed method that behaves as follows. If the user presses the up arrow, the method should output "You
pressed up" using the System.out.println method. If the user presses the down arrow, the method should output "You
pressed down" using the System.out.println method.
Answer:
Answer: A component should be disabled whenever it is inappropriate for the user to interact with it. This minimizes
error handling and special cases.
6
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
7) Write a segment of code that will use a dialog box to ask a user to enter their age. Their age will then be stored in an int
variable named userAge. Assume that the necessary import statements to support the dialog box are already in place.
Answer:
int userAge;
String ageStr; // used for user's response
ageStr = JOptionPane.showInputDialog("How old are you"?);
userAge = Integer.parseInt(ageStr);
8) Write a short class that represents a panel with a single radio button that has the option "Yes" and the option "No." By
default, the Yes button should be checked.
Answer:
import javax.swing.*;
import java.awt.*;
public RadioPanel() {
yes = new JRadioButton("Yes", true);
no = new JradioButton("No");
add(yes);
add(no);
} // end constructor
9) Suppose we have created a class called MyGUI, which represents a GUI. Write a program that creates a JFrame object,
adds a MyGUI object to the frame and makes it visible.
Answer:
import javax.swing.*;
frame.getContentPane().add(new MyGUI());
frame.pack();
frame.setVisible(true);
} // end main
} // end class MyGUIDisplayer
7
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
10) Write a short class that represents a panel with a single slider that has values from 0 to 250, with large tick marks in
increments of 50 and small tick marks in increments of 10.
Answer:
import javax.swing.*;
import java.awt.*;
public SlidePanel() {
slide = new Jslider(JSlider.HORIZONTAL, 0, 255, 0);
slide.setMajorTickSpacing(50);
slide.setMinorTickSpacing(10);
slide.setPaintTicks(true);
slide.setPaintLabels(true);
add(slide);
} // end constructor
} // end class SlidePanel
Answer: Border layout is divided into five areas: North, South, East, West and Center. The North and South areas are
at the top and bottom of the container, respectively, and span the entire width of the container. Sandwiched between them,
from left to right, are the West, Center, and East areas. Any unused area takes up no space, and the others fill in as needed.
12) One of the fundamental ideas of good GUI design is to "know the user". How does "know the user" influence a GUI
design?
Answer: The software has to meet the user's needs. This means not only that it has to do what it is designed to do, but
it also must be software that the user understands how to use. It needs to have an interface that the user is comfortable with in
order to be usable and useful to the user. A person who designs a GUI without an awareness of the user's preferences or skills
is less likely to please the user than someone who takes these into consideration.
Answer: A mnemonic is a character that allows the user to push a button or make a menu choice using the keyboard in
addition to the mouse. A tool-top is a short line of text that will appear when the cursor is rested momentarily on top of the
component. The difference is that the mnemonic allows for more flexibility on the users end (it allows for multiple methods of
achieving the same task), which a tool-tip is simply a helpful reminder of the role of a particular component and offers no
flexibility on the users end.
8
Pearson © 2017
Java Foundations: Introduction to Program Design & Data Structures, 4/e
John Lewis, Peter DePasquale, Joseph Chase
Test Bank: Chapter 6
14) Describe the difference between a heavyweight container and a lightweight container. Give an example of each.
Answer: A heavyweight container is a container that is managed by the underlying operating system on which the
program is run, whereas a lightweight container is managed by the Java program itself. A frame is an example of a heavyweight
container and a panel is a lightweight container.
15) When using a box layout, how is the orientation – horizontal or vertical box – specified?
9
Pearson © 2017
Other documents randomly have
different content
la rue que dans la boutique. Lorsque je mets après un mot
argot des voyous au lieu d'argot des voleurs, c'est que ce
mot, quoique ayant appartenu peut-être d'abord à la langue
des prisons, est d'un usage plus fréquent sur les lèvres des
voyous que dans la bouche des voleurs. De même pour
l'argot des faubouriens, qui n'est pas l'argot des ouvriers,
quoique les ouvriers habitent ordinairement les faubourgs de
Paris. De même pour l'argot des filles, qui n'est pas l'argot
des petites dames ou de Breda-Street, quoique les unes et
les autres exercent la même profession,—avec un public
différent. Certains argots confinent, comme certains
métiers; ils marchent sur une lisière commune, comme
certaines agrégations d'individus; ils voisinent pour ainsi
dire, comme certaines positions sociales: assurément ils
finiront par s'étreindre, par se mêler, par se confondre; le
voyou finira par devenir voleur, la petite dame par être fille,
l'ouvrier par se faire faubourien, etc., mais jusqu'à ce que la
barrière soit franchie, la délimitation effacée, chacun d'eux
aura son accent, sa couleur, auxquels on les pourra
reconnaître. Voilà pourquoi j'ai parqué d'autorité ce mot
dans cette catégorie et non pas dans cette autre, qui a l'air
d'être la même,—comme le violet est le bleu; voilà pourquoi
j'ai cloué sur ce mot cette étiquette et non pas cette autre,
assuré que j'étais de ne pas me tromper; je le maintiens et
le maintiendrai jusqu'au feu,—exclusivé.
Pour l'étymologie, c'est autre chose. Peut-être, à ce propos,
s'étonnera-t-on de la persistance que je mets à redresser les
erreurs et à corriger les bévues de quelques-uns de mes
devanciers, et, de ma part, à moi, philologue de fraîche date
et ignorant de naissance, cela semblera outrecuidant. Je
souscris d'avance à tous les reproches qu'on me fera
l'honneur de m'adresser, même à ceux que je mérite le
moins.
L'étymologie,—et je ne prends pas ce mot dans l'acception
restreinte et purement grammaticale que lui donne Charles
Nodier, qui en fait la norma, la ratio scribendi, l'orthographe
enfin de toutes les langues de dernière formation,—
l'étymologie telle que l'entendent tant de savantes
personnes ne doit pas être considérée autrement que
comme un pur et simple exercice d'imagination. Heureux les
savants qui ont de l'esprit et qui n'ont pas d'imagination: ils
amusent et, accessoirement, instruisent. Ceux qui ont de
l'imagination, au contraire, en ont trop, et non seulement ils
n'instruisent pas, mais encore,—ce qui est plus grave et
moins pardonnable,—ils n'amusent personne, pas même
eux. L'esprit—on me passera cette fatuité de le définir,—est
la raison elle-même, la raison enjouée, folâtre même, mais
la raison: c'est une boussole. L'imagination, elle, n'est
qu'une faculté superfétative, secondaire, qui joue le rôle de
cinquième roue à un carrosse, et qui, si elle n'empêche pas
l'esprit de marcher, ne l'y aide du moins en aucune façon;
quand elle va de conserve avec lui, c'est bien, nul ne s'en
plaint; mais quand elle vole seule, elle perd aisément le nord
et s'égare en égarant les autres.
Je ne veux pas me prononcer au sujet de l'esprit ou de
l'imagination de mes devanciers, de peur de les fâcher avec
un compliment—ou de leur faire plaisir avec une
épigramme. Ce n'est pas le lieu d'ailleurs. Mes devanciers
ont agi à leur guise, d'après les inspirations de leur génie
particulier: je ne les en blâme—ni ne les en loue. Je regrette
seulement—pour eux—que quelques-uns d'entre eux n'aient
pas su éviter l'écueil contre lequel sont venus échouer avant
eux tant d'autres étymologistes trop savants,—par exemple
Ménage, qui fait venir canaille de canalis quand il avait canis
sous la main. M. Marty-Laveaux le disait très pertinemment:
les savants comme Ménage et quelques-uns de mes
devanciers vont chercher trop loin leurs étymologies [9], et
c'est dans ces voyages au long cours qu'ils rencontrent
l'écueil en question. Il est si simple de rester au coin de son
feu, les coudes sur la table, les pieds sur les chenets,
comme un honnête bourgeois sans prétention, qui trouve
sans peine parce qu'il cherche sans effort! L'effort, voilà ce
qui a gâté tant de savants livres!
L'étymologie, étant une maladie, a sa contagion; moi,
parvulissime, j'ai fait comme les grands docteurs de
l'Université de Marburg—et d'ailleurs: je me suis lancé à
fond de train dans le champ des hypothèses, et si je ne suis
pas parvenu à me casser les reins, j'ai du moins donné
quelques entorses au bon sens et à la vérité étymologique.
C'est un jeu comme un autre, amusant pour soi, fatigant
pour autrui, dont cependant je n'ai pas cru devoir abuser,
ainsi qu'on s'en assurera en feuilletant ce volume. Il peut se
faire que, dans cette course vagabonde à travers des
origines probables, j'aie quelquefois rencontré juste et que
quelques-unes de mes trouvailles involontaires méritent
d'être prises en considération: ces bonnes fortunes arrivent
souvent aux innocents, paraît-il. «Quand on ne sait que ce
qu'on a appris, on peut être un savant et un sot; il faut de
plus savoir ce qu'on a deviné.» J.-B. Say avait raison,
quoique économiste. En tout cas, heureux ou non dans mes
devinettes étymologiques, à mon su ou à mon insu, je m'en
tiens à ces premiers essais et m'engage à ne plus jamais
recommencer.
VI
LANGUE VERTE
A.
ABADIE, s. f. Foule,—dans l'argot des voleurs, qui l'appellent
ainsi, avec mépris, parce qu'ils ont remarqué qu'elle se
compose de badauds, de gens qui ouvrent les yeux, la
bouche et les oreilles d'une façon démesurée.
ABAJOUES, s. f. pl. La face,—dans l'argot du peuple.
Il n'est pas de mots que les hommes n'aient inventés pour se prouver le mutuel
mépris dans lequel ils se tiennent. Un des premiers de ce dictionnaire est une injure,
puisque jusqu'ici l'abajoue signifiait soit le sac que certains animaux ont dans la
bouche, soit la partie latérale d'une tête de veau ou d'un groin de cochon. Nous
sommes loin de l'os sublime dedit. Mais nous en verrons bien d'autres.
Avoir les abatis canailles. Avoir les extrémités massives, grosses mains et larges
pieds, qui témoignent éloquemment d'une origine plébéienne.
Cette expression, qui sort du Romancero, est toujours employée par le peuple.
On a dit cela de Mirabeau, et on le dit tous les jours des gens dont le visage
ressemble comme le sien à une tumeur.
C'est un mot du XIIIe siècle, que quelques écrivains modernes s'imaginent avoir
fabriqué; on l'écrivait alors abaylarder,—avec la même signification, bien entendu.
Signifie encore Venir, Arriver sans délai, précipitamment, comme une boule.
D'où l'expression proverbiale: Un bon cheval va bien tout seul à l'abreuvoir, pour
dire: Un ivrogne n'a pas besoin d'y être invité pour aller au cabaret.
Signifie aussi Cracher en parlant. On a dit à propos d'un homme de lettres connu par
son bavardage et ses postillons: «X... demande son absinthe, on la lui apporte, il
parle art ou politique pendant un quart d'heure,—et son absinthe est faite.»
Être de bon acabit. Avoir un excellent caractère, ou jouir d'une excellente santé.
J'ai souligné à dessein coin et chien: c'est la double étymologie de ce verbe, que
n'osent pas employer les gens du bel air, quoiqu'il ait eu l'honneur de monter dans
les carrosses du roi Henri IV. (V. les lettres de ce prince.) S'acagnarder vient en effet
du latin canis, chien, ou du vieux français cagnard, lieu retiré, solitaire,—coin.
On dit aussi s'acagnarder dans un fauteuil.
Se dit aussi d'un chapeau ordinaire sur lequel on s'est assis par mégarde.
Les faubouriens donnent le même nom à leurs favoris,—selon eux irrésistibles sur le
beau sexe, comme les favoris temporaux du beau sexe sont irrésistibles sur nous.
Acrée donc! Cette interjection, qui signifie «Tais-toi!» se jette à voix basse pour
avertir qu'un nouvel arrivant est ou peut être suspect. On dit aussi Nibé donc!
«. . . . . . . . . . . . . . . . . . . Ce qui me console,
C'est que la pauvreté comme moi les affole,»
dit Mathurin Regnier.
Ne serait-ce pas une corruption d'abonir, faire honte, un vieux verbe français encore
employé en Normandie ainsi qu'agonir.
On dit aussi Agoniser.
(V. A Chaillot!)
C'est à dessein que je donne cette orthographe, qui est aussi véritable,—c'est-à-dire
aussi problématique,—que l'orthographe officielle, aigrefin. Le peuple prononce le
nom comme je l'écris: est-ce par euphonie, est-ce par tradition? je l'ignore, et les
savants n'en savent pas plus que moi là-dessus «Aigre faim, faim très vive (homme
affamé)», dit Littré. Sans doute, mais il y a eu jadis une monnaie dite aiglefin, et les
escrocs ne sont pas moins affamés d'argent que d'autre chose.
Se dit aussi du boniment que font les saltimbanques et les marchands forains pour
exciter la curiosité des badauds.
L'expression est vieille.
On dit aussi Allumer son gaz,—ce qui, en effet, est une manière de prendre feu.
ALLUMEUR, s. m. Compère, homme qui fait de fausses
enchères,—dans l'argot des habitués de l'hôtel Drouot.
ALLUMEUSE, s. f. Marcheuse, dans l'argot des filles.
ALPAGA, s. m. Habit, dans l'argot des voleurs et des
faubouriens.
ALPHONSE, s. m. Nom d'homme qui est devenu—dans l'argot
des filles—celui de tous les hommes assez peu délicats
pour se laisser aimer et payer par elles.
ALPIOU, s. m. Homme qui triche au jeu,—par allusion au nom
donné autrefois à la marque que l'on faisait à sa carte en
jouant à la bassette.
ALTÈQUE, ad. Beau, brave, excellent,—dans l'argot des voleurs,
qui ont emprunté ce mot (altus) à Virgile.
AMADOU, s. m. «C'est dequoy les argotiers se frottent pour se
faire devenir jaunes et paraistre malades,»—c'est-à-dire
pour amadouer et tromper les bonnes âmes.
AMADOU, s. et adj. Homme qui prend aisément feu—afin d'être
aimé, amatus. Argot du peuple.
AMADOUAGE, s. m. Mariage—dans l'argot des voleurs.
AMADOUÉ, s. m. Homme marié.
AMADOUER (S') v. réfl. Se grimer pour tromper. Même argot.
AMANDES DE PAIN D'ÉPICE, s. f. pl. Dents noires et rares. Argot
des faubouriens.
Pierre Sarrazin avait déjà employé ce mot dans le même sens, en l'écrivant ainsi:
arresoner; je l'ai cherché en vain dans les dictionnaires. D'un autre côté, les voleurs
disent: Faire l'arçon, pour signifier: Faire le signal de reconnaissance ou
d'avertissement, qui est, paraît-il, le bruit d'un crachement et le dessin d'un C sur la
joue droite, près du menton, avec le pouce de la main droite.
Ils disent aristo pour aristocrate, comme sous la Fronde les pamphlétaires disaient
Maza pour Mazarin.
testbankdeal.com