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

12 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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?

  1. A radio button, which is already selected.
  2. A radio button, which is not selected.
  3. A push button, which is already selected.
  4. A push button, which is not selected.
  5. No output
Question 2 Multiple Choice (Single Answer)

Which of the following objects in Java is notified when an event occurs?

  1. Event Source
  2. Event Object
  3. Event Listener
  4. None of these
Question 3 Multiple Choice (Single Answer)

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);
 }
}
  1. Frame is not defined properly.
  2. Statement import java.awt.*; is missing.
  3. Statement import java.net.*; is missing.
  4. Statement import java.io.*; is missing.
  5. Set size is not defined properly.
Question 4 Multiple Choice (Single Answer)

Which of the following constants in AdjustmentEvent class acts as a button used at the end of the scroll bar to decrease its value?

  1. BLOCK_DECREMENT
  2. BLOCK_INCREMENT
  3. UNIT_INCREMENT
  4. UNIT_DECREMENT
Question 5 Multiple Choice (Single Answer)

Which of the following interfaces in event listener interface defines one method to recognize when a text value changes?

  1. WindowListener
  2. KeyListener
  3. TextListener
  4. ActionListener
Question 6 Multiple Choice (Single Answer)

Which of the following terminologies in FontMetrics class defines the distance from the baseline to the top of a character?

  1. Height
  2. Ascent
  3. Descent
  4. Leading
Question 7 Multiple Choice (Single Answer)

Which of the following methods of Font class returns the name of the font family to which the invoking font belongs?

  1. getFontName()
  2. getName()
  3. getStyle()
  4. getFamily()
Question 8 Multiple Choice (Single Answer)

Which method of ItemEvent can be used to obtain reference to the ItemSelectable objects that generate an event?

  1. getItem()
  2. getItemSelectable()
  3. getStateChange()
  4. none of these
Question 9 Multiple Choice (Single Answer)

Which event is generated when a component gains or loses input focus?

  1. Focus Event
  2. Keyboard Event
  3. Text Event
  4. Mouse Event
Question 10 Multiple Choice (Single Answer)

In Java Programming Language, which classes implement the corresponding listener interfaces containing more than one method?

  1. Adapter classes
  2. Inner classes
  3. Anonymous classes
  4. Window classes
Question 11 Multiple Choice (Single Answer)

______________ is generated by text fields and text areas when characters are entered by a user or program.

  1. Focus Event
  2. Item Event
  3. Text Event
  4. None of these
Question 12 Multiple Choice (Single Answer)

Which method of MouseEvent obtains the number of mouse clicks for the event?

  1. translatePoint()
  2. getClickCount()
  3. isPopupTrigger()
  4. getitem()