Batts
Test por , creado hace más de 1 año

Fall 2014

1858
0
0
Batts
Creado por Batts hace más de 9 años
Cerrar

Java Test 2

Pregunta 1 de 49

1

Which components contains menus?

Selecciona una de las siguientes respuestas posibles:

  • Menu button

  • Title bar

  • Menu bar

  • Combo box

Explicación

Pregunta 2 de 49

1

Which of the following statements for a JTextField is FALSE?

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 3 de 49

1

Which of the following statements about heavyweight components is FALSE?

Selecciona una de las siguientes respuestas posibles:

  • 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

Explicación

Pregunta 4 de 49

1

Which pair of words does NOT complete the sentence below correctly?
A ______ is a _______.

Selecciona una de las siguientes respuestas posibles:

  • Container, Component

  • Container, JPanel

  • JComponent, Container

  • Component, Object

Explicación

Pregunta 5 de 49

1

__________ 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.

Selecciona una de las siguientes respuestas posibles:

  • JLabel

  • JFrame

  • JSwing

  • JWindowControl

Explicación

Pregunta 6 de 49

1

Method ________ can be used to set the layout manager of a container.

Selecciona una de las siguientes respuestas posibles:

  • setManager

  • setLayout

  • setLayoutManager

  • setGUILayout

Explicación

Pregunta 7 de 49

1

A JLabel can be attached to a JFrame using method:

Selecciona una de las siguientes respuestas posibles:

  • attach

  • contain

  • append

  • add

Explicación

Pregunta 8 de 49

1

A JRadioButton is different from a JCheckBox in that _______.

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 9 de 49

1

The logical relationship between radio buttons is maintained by objects of what class?

Selecciona una de las siguientes respuestas posibles:

  • MutualExclusionGroup

  • RadioButtonGroup

  • Group

  • ButtonGroup

Explicación

Pregunta 10 de 49

1

Adding a ButtonGroup object to a container:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 11 de 49

1

JButtons generate what type of event?

Selecciona una de las siguientes respuestas posibles:

  • ActionEvents

  • ChangeEvents

  • WindowEvents

  • MouseEvents

  • Both A and D are correct

Explicación

Pregunta 12 de 49

1

A JFrame supports three operations when the user closes the window.
Which of the choices below is NOT one of the three:

Selecciona una de las siguientes respuestas posibles:

  • DISPOSE_ON_CLOSE

  • DO_NOTHING_ON_CLOSE

  • LOWER_ON_CLOSE

  • HIDE_ON_CLOSE

Explicación

Pregunta 13 de 49

1

Which of the following is not one of the seven methods for handling window events?

Selecciona una de las siguientes respuestas posibles:

  • windowClosing

  • windowClosed

  • windowOpening

  • windowOpened

Explicación

Pregunta 14 de 49

1

Which of the following is FALSE?

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 15 de 49

1

What happens if setSize is not called on a JFrame (assume pack is not called)?

Selecciona una de las siguientes respuestas posibles:

  • The window is displayed at its preferred size

  • It is a syntax error.

  • The window is not displayed.

  • Only the title bar appears.

Explicación

Pregunta 16 de 49

1

Which of the following does NOT generate GUI events?

Selecciona una de las siguientes respuestas posibles:

  • Selecting an item from a menu.

  • Displaying the text in a label.

  • Moving the mouse.

  • Typing in a text field.

Explicación

Pregunta 17 de 49

1

Which of the following most completely describes the steps for setting up event handling for a GUI component?

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 18 de 49

1

When the user presses Enter in a JTextField, the GUI component generates an _______, which is processed by an object that implements the interface ________ .

Selecciona una de las siguientes respuestas posibles:

  • ActionEvent, ActionListener.

  • ActionEvent, ActionEventListener.

  • TextEvent, TextListener.

  • TextEvent, TextEventListener.

Explicación

Pregunta 19 de 49

1

Forgetting to register an event-handler object for a particular GUI component’s event type causes _______.

Selecciona una de las siguientes respuestas posibles:

  • events of that type to be ignored.

  • all of the GUI component's events to be ignored.

  • a compilation error.

    .

  • None of the above.

Explicación

Pregunta 20 de 49

1

JTextField contains method _______ to obtain the data entered

Selecciona una de las siguientes respuestas posibles:

  • getInput

  • getPassword

  • getText

  • getEcho

Explicación

Pregunta 21 de 49

1

How many even-listener interfaces correspond to each event type?

Selecciona una de las siguientes respuestas posibles:

  • one

  • two

  • one or more

  • zero

Explicación

Pregunta 22 de 49

1

The logical relationship between radio buttons is maintained by objects of what class?

Selecciona una de las siguientes respuestas posibles:

  • MutualExclusionGroup

  • RadioButtonGroup

  • Group

  • ButtonGroup

Explicación

Pregunta 23 de 49

1

Adding a ButtonGroup object to a container:

Selecciona una de las siguientes respuestas posibles:

  • 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

Explicación

Pregunta 24 de 49

1

Which of the following statements about anonymous inner classes is FALSE?

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 25 de 49

1

Which of the following objects CANNOT trap mouse events?

Selecciona una de las siguientes respuestas posibles:

  • JTextField

  • ButtonGroup

  • JButton

  • JComponent

Explicación

Pregunta 26 de 49

1

Which of the following is a MouseMotionListener method?

Selecciona una de las siguientes respuestas posibles:

  • mousePressed

  • mouseExited

  • mouseDragged

  • mouseClicked

Explicación

Pregunta 27 de 49

1

A MouseHandler object implements which TWO interfaces?

Selecciona una de las siguientes respuestas posibles:

  • MouseListener and MouseActionListener

  • MouseListener and MouseMotionListener

  • MouseListener and MouseEventListener

  • MouseListener only

Explicación

Pregunta 28 de 49

1

In what cases are adapter classes useful?

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 29 de 49

1

Which of the following is NOT a KeyListener method?

Selecciona una de las siguientes respuestas posibles:

  • keyPressed

  • keyReleased

  • keyClicked

  • keyTyped

Explicación

Pregunta 30 de 49

1

Which of the following classes is not used for file input?

Selecciona una de las siguientes respuestas posibles:

  • FileInputStream

  • FileReader

  • ObjectInputStream

  • Formatter

Explicación

Pregunta 31 de 49

1

Streams that input bytes from and output bytes to files are known as:

Selecciona una de las siguientes respuestas posibles:

  • bit-based streams

  • byte-based streams

  • character-based streams

  • Unicode-based streams

Explicación

Pregunta 32 de 49

1

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.

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 33 de 49

1

Which of the following is not an application of a File object?

Selecciona una de las siguientes respuestas posibles:

  • Open or edit a file.

  • Determine if a file exists.

  • Determine whether a file is readable.

  • Determine whether a file is writable.

Explicación

Pregunta 34 de 49

1

When all the contents of a file are truncated, this means that:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 35 de 49

1

To catch an exception, the code that might throw the exception must be enclosed in a

Selecciona una de las siguientes respuestas posibles:

  • throws block

  • catch block

  • try block

  • finally block

Explicación

Pregunta 36 de 49

1

In the catch block below, what is arithmeticException?

catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
}
// end catch

Selecciona una de las siguientes respuestas posibles:

  • The type of the exception being caught.

  • The name of catch block’s exception parameter.

  • A finally block.

  • An exception handler.

Explicación

Pregunta 37 de 49

1

An uncaught exception:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 38 de 49

1

Which of the following exceptions is a checked exception?

Selecciona una de las siguientes respuestas posibles:

  • ArithmeticException

  • IOException.

  • RuntimeException.

  • InputMismatchException.

Explicación

Pregunta 39 de 49

1

If the catch-or-declare requirement for a checked exception is not satisfied:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 40 de 49

1

In the Java coordinate system, the point (0, 0) is:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 41 de 49

1

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.

Selecciona una de las siguientes respuestas posibles:

  • A, C, E.

  • C, D, E.

  • A, B, D, E.

  • All are true.

Explicación

Pregunta 42 de 49

1

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 );

Selecciona una de las siguientes respuestas posibles:

  • All of the above.

  • A, B, C.

  • A, B, D.

  • A, B.

Explicación

Pregunta 43 de 49

1

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" );

Selecciona una de las siguientes respuestas posibles:

  • A and B

  • B and C.

  • B.

  • D.

Explicación

Pregunta 44 de 49

1

Method getFont of class Graphics returns:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 45 de 49

1

The Java statement:
g.fillOval( 290, 100, 90, 55 );

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación

Pregunta 46 de 49

1

The Java statement:
g.draw3DRect( 290, 100, 90, 55, true );

Selecciona una de las siguientes respuestas posibles:

  • 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).

Explicación

Pregunta 47 de 49

1

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?

Selecciona una de las siguientes respuestas posibles:

  • Rectangle

  • Triangle

  • A V with its corner at the top.

  • Square

Explicación

Pregunta 48 de 49

1

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?

Selecciona una de las siguientes respuestas posibles:

  • 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 );

Explicación

Pregunta 49 de 49

1

The fact that class Graphics is abstract contributes to Java’s portability because:

Selecciona una de las siguientes respuestas posibles:

  • 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.

Explicación