Questão 1
Questão
Which components contains menus?
Responda
-
Menu button
-
Title bar
-
Menu bar
-
Combo box
Questão 2
Questão
Which of the following statements for a JTextField is FALSE?
Responda
-
Can be used to display un-editable text.
-
Can be used to display editable text.
-
Enables users to enter data from the keyboard.
-
Displays a list of fields.
Questão 3
Questão
Which of the following statements about heavyweight components is FALSE?
Responda
-
AWT components are not heavyweight components
-
Several Swing components are heavyweight components
-
The look-and-feel may vary across platforms
-
The functionality may vary across platforms
Questão 4
Questão
Which pair of words does NOT complete the sentence below correctly?
A ______ is a _______.
Responda
-
Container, Component
-
Container, JPanel
-
JComponent, Container
-
Component, Object
Questão 5
Questão
__________ 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.
Responda
-
JLabel
-
JFrame
-
JSwing
-
JWindowControl
Questão 6
Questão
Method ________ can be used to set the layout manager of a container.
Responda
-
setManager
-
setLayout
-
setLayoutManager
-
setGUILayout
Questão 7
Questão
A JLabel can be attached to a JFrame using method:
Responda
-
attach
-
contain
-
append
-
add
Questão 8
Questão
A JRadioButton is different from a JCheckBox in that _______.
Responda
-
a JRadioButton is a subclass of JToggleButton, JCheckBox is not.
-
normally several JRadioButtons are grouped together and are mutually exclusive.
-
a JRadioButton is a type of button, JCheckBox is not
-
a JRadioButton is a state button, JCheckBox is not.
Questão 9
Questão
The logical relationship between radio buttons is maintained by objects of what class?
Responda
-
MutualExclusionGroup
-
RadioButtonGroup
-
Group
-
ButtonGroup
Questão 10
Questão
Adding a ButtonGroup object to a container:
Responda
-
is necessary for the functionality of the ButtonGroup to work properly.
-
causes all the JRadioButtons in the group to have their event handlers registered.
-
results in a compilation error.
-
None of the above.
Questão 11
Questão
JButtons generate what type of event?
Responda
-
ActionEvents
-
ChangeEvents
-
WindowEvents
-
MouseEvents
-
Both A and D are correct
Questão 12
Questão
A JFrame supports three operations when the user closes the window.
Which of the choices below is NOT one of the three:
Responda
-
DISPOSE_ON_CLOSE
-
DO_NOTHING_ON_CLOSE
-
LOWER_ON_CLOSE
-
HIDE_ON_CLOSE
Questão 13
Questão
Which of the following is not one of the seven methods for handling window events?
Responda
-
windowClosing
-
windowClosed
-
windowOpening
-
windowOpened
Questão 14
Questão
Which of the following is FALSE?
Responda
-
JFrame is a lightweight component.
-
JFrame is a subclass of Frame (which is a subclass of Window).
-
JFrames have a title bar and a border.
-
A JFrame window will look like all other windows displayed on that platform.
Questão 15
Questão
What happens if setSize is not called on a JFrame (assume pack is not called)?
Responda
-
The window is displayed at its preferred size
-
It is a syntax error.
-
The window is not displayed.
-
Only the title bar appears.
Questão 16
Questão
Which of the following does NOT generate GUI events?
Questão 17
Questão
Which of the following most completely describes the steps for setting up event handling for a GUI component?
Responda
-
Create a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler.
-
Implement an appropriate event-listener interface and register the event handler.
-
Create a class that represents the event handler and implement an appropriate event-listener interface.
-
Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.
Questão 18
Questão
When the user presses Enter in a JTextField, the GUI component generates an _______, which is processed by an object that implements the interface ________ .
Responda
-
ActionEvent, ActionListener.
-
ActionEvent, ActionEventListener.
-
TextEvent, TextListener.
-
TextEvent, TextEventListener.
Questão 19
Questão
Forgetting to register an event-handler object for a particular GUI component’s event type causes _______.
Questão 20
Questão
JTextField contains method _______ to obtain the data entered
Responda
-
getInput
-
getPassword
-
getText
-
getEcho
Questão 21
Questão
How many even-listener interfaces correspond to each event type?
Questão 22
Questão
The logical relationship between radio buttons is maintained by objects of what class?
Responda
-
MutualExclusionGroup
-
RadioButtonGroup
-
Group
-
ButtonGroup
Questão 23
Questão
Adding a ButtonGroup object to a container:
Responda
-
is necessary for the functionality of the ButtonGroup to work properly.
-
causes all the JRadioButtons in the group to have their event handlers registered.
-
results in a compilation error.
-
none of the above
Questão 24
Questão
Which of the following statements about anonymous inner classes is FALSE?
Responda
-
They are declared without a name.
-
They typically appear inside a method declaration.
-
They are declared with the anonymous keyword.
-
They can access their top-level class’s members.
Questão 25
Questão
Which of the following objects CANNOT trap mouse events?
Responda
-
JTextField
-
ButtonGroup
-
JButton
-
JComponent
Questão 26
Questão
Which of the following is a MouseMotionListener method?
Responda
-
mousePressed
-
mouseExited
-
mouseDragged
-
mouseClicked
Questão 27
Questão
A MouseHandler object implements which TWO interfaces?
Responda
-
MouseListener and MouseActionListener
-
MouseListener and MouseMotionListener
-
MouseListener and MouseEventListener
-
MouseListener only
Questão 28
Questão
In what cases are adapter classes useful?
Responda
-
When an adapter GUI control is clicked.
-
When every method in the event-listener interface is to use the same functionality.
-
When it is not desirable to declare every method in the event-listener interface.
-
None of the above.
Questão 29
Questão
Which of the following is NOT a KeyListener method?
Responda
-
keyPressed
-
keyReleased
-
keyClicked
-
keyTyped
Questão 30
Questão
Which of the following classes is not used for file input?
Responda
-
FileInputStream
-
FileReader
-
ObjectInputStream
-
Formatter
Questão 31
Questão
Streams that input bytes from and output bytes to files are known as:
Responda
-
bit-based streams
-
byte-based streams
-
character-based streams
-
Unicode-based streams
Questão 32
Questão
Which 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.
Responda
-
File name = new File( "c:\\books\\2009", "files.txt" );
-
File name = new File( "files.txt" );
-
File name = new File( "2009", "files.txt" );
-
All of the above are equivalent to the statement in the question.
Questão 33
Questão
Which of the following is not an application of a File object?
Responda
-
Open or edit a file.
-
Determine if a file exists.
-
Determine whether a file is readable.
-
Determine whether a file is writable.
Questão 34
Questão
When all the contents of a file are truncated, this means that:
Responda
-
the data in the file is saved to a backup file.
-
the file is deleted.
-
a FileNotFoundException occurs.
-
All the data in the file is discarded.
Questão 35
Questão
To catch an exception, the code that might throw the exception must be enclosed in a
Responda
-
throws block
-
catch block
-
try block
-
finally block
Questão 36
Questão
In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
}
// end catch
Questão 37
Questão
An uncaught exception:
Responda
-
is a possible exception that never actually occurs during the execution of the program.
-
is an exception that occurs for which the matching catch clause is empty.
-
is an exception that occurs for which there are no matching catch clauses.
-
is another term for a thrown exception.
Questão 38
Questão
Which of the following exceptions is a checked exception?
Responda
-
ArithmeticException
-
IOException.
-
RuntimeException.
-
InputMismatchException.
Questão 39
Questão
If the catch-or-declare requirement for a checked exception is not satisfied:
Responda
-
the compiler will issue an error message indicating that the exception must be caught.
-
the compiler will issue an error message indicating that the exception must be caught or declared.
-
a stack trace will be displayed indicating the exception that has occurred and where it occurred.
-
a stack trace will be displayed, along with a message indicating that the exception must be caught.
Questão 40
Questão
In the Java coordinate system, the point (0, 0) is:
Responda
-
The lower-right corner of the screen.
-
The upper-right corner of the screen.
-
The lower-left corner of the screen.
-
The upper-left corner of the screen.
Questão 41
Questão
Which 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.
Responda
-
A, C, E.
-
C, D, E.
-
A, B, D, E.
-
All are true.
Questão 42
Questão
Which 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 );
Responda
-
All of the above.
-
A, B, C.
-
A, B, D.
-
A, B.
Questão 43
Questão
Which 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" );
Questão 44
Questão
Method getFont of class Graphics returns:
Responda
-
the current font name as a string.
-
the font size in points.
-
a Graphics object representing the current font.
-
a Font object representing the current font.
Questão 45
Questão
The Java statement:
g.fillOval( 290, 100, 90, 55 );
Responda
-
Draws a filled oval with its center at coordinates x=290, y=100, with height=90 and width=55.
-
Draws a filled oval with its left most point at coordinates x=290, y=100, with height=90 and width=55.
-
Draws a filled oval bounded by a rectangle with its upper left corner at coordinates x=290, y=100, with width=90 and height=55.
-
Draws a filled oval bounded by a rectangle with its upper left corner at coordinates x=290, y=100, with height=90 and width=55.
Questão 46
Questão
The Java statement:
g.draw3DRect( 290, 100, 90, 55, true );
Responda
-
draws a rectangle that appears to be raised (the top and left edges of the rectangle are slightly darker than the rectangle).
-
draws a rectangle that appears to be lowered (the bottom and right edges of the rectangle are slightly darker than the rectangle).
-
draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).
-
draws a rectangle that appears to be lowered (the top and left edges of the rectangle are slightly darker than the rectangle).
Questão 47
Questão
Consider 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?
Questão 48
Questão
Consider 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?
Responda
-
poly2.addPoint( 100, 60 );
poly2.addPoint( 100, 130 );
-
poly2.addPoint( 200, 130 );
poly2.addPoint( 200, 30 );
-
poly2.addPoint( 200, 60 );
poly2.addPoint( 200, 130 );
-
poly2.addPoint( 100, 130 );
poly2.addPoint( 100, 230 );
Questão 49
Questão
The fact that class Graphics is abstract contributes to Java’s portability because:
Responda
-
drawing 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.
-
objects of non-abstract classes can only be instantiated on the Windows platform.
-
drawing should not be performed on non-Linux platforms.
-
Class Graphics is not abstract.