Quiz
Java Test 2
Crie uma conta grátis para terminar este quiz
Salve seu progresso e veja sua nota final.
Já tem uma conta? Inicie sessão
Perguntas do quiz (49)
1Which components contains menus?
- AMenu button
- BTitle bar
- CMenu bar
- DCombo box
2Which of the following statements for a JTextField is FALSE?
- ACan be used to display un-editable text.
- BCan be used to display editable text.
- CEnables users to enter data from the keyboard.
- DDisplays a list of fields.
3Which of the following statements about heavyweight components is FALSE?
- AAWT components are not heavyweight components
- BSeveral Swing components are heavyweight components
- CThe look-and-feel may vary across platforms
- DThe functionality may vary across platforms
4Which pair of words does NOT complete the sentence below correctly?
A ______ is a _______.- AContainer, Component
- BContainer, JPanel
- CJComponent, Container
- DComponent, Object
5__________ provides the basic attributes and behaviors of a window — a title bar at the top of the window, and buttons to minimize, maximize and close the window.
- AJLabel
- BJFrame
- CJSwing
- DJWindowControl
6Method ________ can be used to set the layout manager of a container.
- AsetManager
- BsetLayout
- CsetLayoutManager
- DsetGUILayout
7A JLabel can be attached to a JFrame using method:
- Aattach
- Bcontain
- Cappend
- Dadd
8A JRadioButton is different from a JCheckBox in that _______.
- Aa JRadioButton is a subclass of JToggleButton, JCheckBox is not.
- Bnormally several JRadioButtons are grouped together and are mutually exclusive.
- Ca JRadioButton is a type of button, JCheckBox is not
- Da JRadioButton is a state button, JCheckBox is not.
9The logical relationship between radio buttons is maintained by objects of what class?
- AMutualExclusionGroup
- BRadioButtonGroup
- CGroup
- DButtonGroup
10Adding a ButtonGroup object to a container:
- Ais necessary for the functionality of the ButtonGroup to work properly.
- Bcauses all the JRadioButtons in the group to have their event handlers registered.
- Cresults in a compilation error.
- DNone of the above.
11JButtons generate what type of event?
- AActionEvents
- BChangeEvents
- CWindowEvents
- DMouseEvents
- EBoth A and D are correct
12A JFrame supports three operations when the user closes the window.
Which of the choices below is NOT one of the three:- ADISPOSE_ON_CLOSE
- BDO_NOTHING_ON_CLOSE
- CLOWER_ON_CLOSE
- DHIDE_ON_CLOSE
13Which of the following is not one of the seven methods for handling window events?
- AwindowClosing
- BwindowClosed
- CwindowOpening
- DwindowOpened
14Which of the following is FALSE?
- AJFrame is a lightweight component.
- BJFrame is a subclass of Frame (which is a subclass of Window).
- CJFrames have a title bar and a border.
- DA JFrame window will look like all other windows displayed on that platform.
15What happens if setSize is not called on a JFrame (assume pack is not called)?
- AThe window is displayed at its preferred size
- BIt is a syntax error.
- CThe window is not displayed.
- DOnly the title bar appears.
16Which of the following does NOT generate GUI events?
- ASelecting an item from a menu.
- BDisplaying the text in a label.
- CMoving the mouse.
- DTyping in a text field.
17Which of the following most completely describes the steps for setting up event handling for a GUI component?
- ACreate a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler.
- BImplement an appropriate event-listener interface and register the event handler.
- CCreate a class that represents the event handler and implement an appropriate event-listener interface.
- DCreate a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.
18When the user presses Enter in a JTextField, the GUI component generates an _______, which is processed by an object that implements the interface ________ .
- AActionEvent, ActionListener.
- BActionEvent, ActionEventListener.
- CTextEvent, TextListener.
- DTextEvent, TextEventListener.
- AActionEvent, ActionListener.
19Forgetting to register an event-handler object for a particular GUI component’s event type causes _______.
- Aevents of that type to be ignored.
- Ball of the GUI component's events to be ignored.
- Ca compilation error.
. - DNone of the above.
20JTextField contains method _______ to obtain the data entered
- AgetInput
- BgetPassword
- CgetText
- DgetEcho
21How many even-listener interfaces correspond to each event type?
- Aone
- Btwo
- Cone or more
- Dzero
22The logical relationship between radio buttons is maintained by objects of what class?
- AMutualExclusionGroup
- BRadioButtonGroup
- CGroup
- DButtonGroup
23Adding a ButtonGroup object to a container:
- Ais necessary for the functionality of the ButtonGroup to work properly.
- Bcauses all the JRadioButtons in the group to have their event handlers registered.
- Cresults in a compilation error.
- Dnone of the above
24Which of the following statements about anonymous inner classes is FALSE?
- AThey are declared without a name.
- BThey typically appear inside a method declaration.
- CThey are declared with the anonymous keyword.
- DThey can access their top-level class’s members.
25Which of the following objects CANNOT trap mouse events?
- AJTextField
- BButtonGroup
- CJButton
- DJComponent
26Which of the following is a MouseMotionListener method?
- AmousePressed
- BmouseExited
- CmouseDragged
- DmouseClicked
27A MouseHandler object implements which TWO interfaces?
- AMouseListener and MouseActionListener
- BMouseListener and MouseMotionListener
- CMouseListener and MouseEventListener
- DMouseListener only
28In what cases are adapter classes useful?
- AWhen an adapter GUI control is clicked.
- BWhen every method in the event-listener interface is to use the same functionality.
- CWhen it is not desirable to declare every method in the event-listener interface.
- DNone of the above.
29Which of the following is NOT a KeyListener method?
- AkeyPressed
- BkeyReleased
- CkeyClicked
- DkeyTyped
30Which of the following classes is not used for file input?
- AFileInputStream
- BFileReader
- CObjectInputStream
- DFormatter
31Streams that input bytes from and output bytes to files are known as:
- Abit-based streams
- Bbyte-based streams
- Ccharacter-based streams
- DUnicode-based streams
32Which of the following statements is not equivalent to
File name = new File( "c:\\books\\2009\\files.txt" );
Assume we are currently in the directory c:\books.- AFile name = new File( "c:\\books\\2009", "files.txt" );
- BFile name = new File( "files.txt" );
- CFile name = new File( "2009", "files.txt" );
- DAll of the above are equivalent to the statement in the question.
33Which of the following is not an application of a File object?
- AOpen or edit a file.
- BDetermine if a file exists.
- CDetermine whether a file is readable.
- DDetermine whether a file is writable.
34When all the contents of a file are truncated, this means that:
- Athe data in the file is saved to a backup file.
- Bthe file is deleted.
- Ca FileNotFoundException occurs.
- DAll the data in the file is discarded.
35To catch an exception, the code that might throw the exception must be enclosed in a
- Athrows block
- Bcatch block
- Ctry block
- Dfinally block
36In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
}
// end catch- AThe type of the exception being caught.
- BThe name of catch block’s exception parameter.
- CA finally block.
- DAn exception handler.
37An uncaught exception:
- Ais a possible exception that never actually occurs during the execution of the program.
- Bis an exception that occurs for which the matching catch clause is empty.
- Cis an exception that occurs for which there are no matching catch clauses.
- Dis another term for a thrown exception.
38Which of the following exceptions is a checked exception?
- AArithmeticException
- BIOException.
- CRuntimeException.
- DInputMismatchException.
39If the catch-or-declare requirement for a checked exception is not satisfied:
- Athe compiler will issue an error message indicating that the exception must be caught.
- Bthe compiler will issue an error message indicating that the exception must be caught or declared.
- Ca stack trace will be displayed indicating the exception that has occurred and where it occurred.
- Da stack trace will be displayed, along with a message indicating that the exception must be caught.
40In the Java coordinate system, the point (0, 0) is:
- AThe lower-right corner of the screen.
- BThe upper-right corner of the screen.
- CThe lower-left corner of the screen.
- DThe upper-left corner of the screen.
41Which of the following statements about the Graphics object is true?
A. The Graphics object is an argument to class Component’s repaint method.
B. The Graphics object is instantiated by the user.
C. The Graphics object is the argument to a lightweight GUI component's paintComponent method.
D. The Graphics class is abstract.
E. The Graphics object manages a graphics context.- AA, C, E.
- BC, D, E.
- CA, B, D, E.
- DAll are true.
42Which of the following are valid Java statements?
A. Color c = new Color( 0, 255, 0 );
B. Color c = new Color( 0.0f, 1.0f, 0.0f );
C. Color c = new Color( 0.0d, 1.0d, 0.0d );
D. setGreen( c.getGreen() - 2 );- AAll of the above.
- BA, B, C.
- CA, B, D.
- DA, B.
43Which of the following properly create and initialize a Font object?
A. Font f = new Font();
B. Font f = new Font( "Serif", Font.Bold + Font.Italic, 19 );
C. Font f = new Font( Font.Bold, 20, "SansSerif" );
D. Font f = new Font( 20, Font.Bold, "Monospaced" );- AA and B
- BB and C.
- CB.
- DD.
44Method getFont of class Graphics returns:
- Athe current font name as a string.
- Bthe font size in points.
- Ca Graphics object representing the current font.
- Da Font object representing the current font.
45The Java statement:
g.fillOval( 290, 100, 90, 55 );- ADraws a filled oval with its center at coordinates x=290, y=100, with height=90 and width=55.
- BDraws a filled oval with its left most point at coordinates x=290, y=100, with height=90 and width=55.
- CDraws a filled oval bounded by a rectangle with its upper left corner at coordinates x=290, y=100, with width=90 and height=55.
- DDraws a filled oval bounded by a rectangle with its upper left corner at coordinates x=290, y=100, with height=90 and width=55.
46The Java statement:
g.draw3DRect( 290, 100, 90, 55, true );- Adraws a rectangle that appears to be raised (the top and left edges of the rectangle are slightly darker than the rectangle).
- Bdraws a rectangle that appears to be lowered (the bottom and right edges of the rectangle are slightly darker than the rectangle).
- Cdraws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).
- Ddraws a rectangle that appears to be lowered (the top and left edges of the rectangle are slightly darker than the rectangle).
47Consider the code segment below:
int xValues[] = { 100, 150, 200, 100 };
int yValues[] = { 30, 130, 30, 30 };
g.drawPolyline( xValues, yValues, 4 );
What kind of figure does it draw?- ARectangle
- BTriangle
- CA V with its corner at the top.
- DSquare
48Consider the Java code segment below:
Polygon poly2 = new Polygon();
poly2.addPoint( 100, 30 );
poly2.addPoint( 100, 130 );
Which of the following will create a polygon that is a square?- Apoly2.addPoint( 100, 60 );
poly2.addPoint( 100, 130 ); - Bpoly2.addPoint( 200, 130 );
poly2.addPoint( 200, 30 ); - Cpoly2.addPoint( 200, 60 );
poly2.addPoint( 200, 130 ); - Dpoly2.addPoint( 100, 130 );
poly2.addPoint( 100, 230 );
- Apoly2.addPoint( 100, 60 );
49The fact that class Graphics is abstract contributes to Java’s portability because:
- Adrawing is performed differently on every platform that supports Java. A subclass of Graphics must be created that uses the drawing capabilities of the current platform.
- Bobjects of non-abstract classes can only be instantiated on the Windows platform.
- Cdrawing should not be performed on non-Linux platforms.
- DClass Graphics is not abstract.
Informações
- Descrição
- Fall 2014
- Autor
- Batts
- Idioma
- English
- Visualizações
- 1.961
- Etiquetas
- Avaliação
- Ainda sem avaliações Avalie este quiz