Test 2 on Java Swing and AWT
Intermediate-level quiz covering Java Swing and AWT GUI components, event handling, listeners, adapter classes, and graphics programming
Questions
If a checkbox Group object is passed in a program and in return a false condition is obtained, then what will be its output on the screen?
- A radio button, which is already selected.
- A radio button, which is not selected.
- A push button, which is already selected.
- A push button, which is not selected.
- No output
Which of the following objects in Java is notified when an event occurs?
- Event Source
- Event Object
- Event Listener
- None of these
The following program is written to create a frame. The program seems to be correct but when it is compiled, the compiler is not accepting it. Why?
class Myframe {
public static void main(string_args[]) {
Frame f = new frame("My frame");
f.setsize(300, 250);
f.setvisible(true);
}
}
- Frame is not defined properly.
- Statement import java.awt.*; is missing.
- Statement import java.net.*; is missing.
- Statement import java.io.*; is missing.
- Set size is not defined properly.
Which of the following constants in AdjustmentEvent class acts as a button used at the end of the scroll bar to decrease its value?
- BLOCK_DECREMENT
- BLOCK_INCREMENT
- UNIT_INCREMENT
- UNIT_DECREMENT
Which of the following interfaces in event listener interface defines one method to recognize when a text value changes?
- WindowListener
- KeyListener
- TextListener
- ActionListener
Which of the following terminologies in FontMetrics class defines the distance from the baseline to the top of a character?
- Height
- Ascent
- Descent
- Leading
Which of the following methods of Font class returns the name of the font family to which the invoking font belongs?
- getFontName()
- getName()
- getStyle()
- getFamily()
Which method of ItemEvent can be used to obtain reference to the ItemSelectable objects that generate an event?
- getItem()
- getItemSelectable()
- getStateChange()
- none of these
Which event is generated when a component gains or loses input focus?
- Focus Event
- Keyboard Event
- Text Event
- Mouse Event
In Java Programming Language, which classes implement the corresponding listener interfaces containing more than one method?
- Adapter classes
- Inner classes
- Anonymous classes
- Window classes
______________ is generated by text fields and text areas when characters are entered by a user or program.
- Focus Event
- Item Event
- Text Event
- None of these
Which method of MouseEvent obtains the number of mouse clicks for the event?
- translatePoint()
- getClickCount()
- isPopupTrigger()
- getitem()