0

Test 2 on Java Swings

Description: Test your knowledge of Java Swings
Number of Questions: 15
Created by:
Tags: Swings Programming Java Structure Unions and Enumerations
Attempted 0/15 Correct 0 Score 0

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


Correct Option: B
Explanation:

A radio button will appear on the screen as not selected, when return value is false. 

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


Correct Option: C
Explanation:

This is an object, which is notified when an event occurs.

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.


Correct Option: B
Explanation:

This statement is must, because awt application is used to create the frame. This application is missing.

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


Correct Option: D
Explanation:

This constant in AdjustmentEvent class acts as a button used at the end of the scroll bar to decrease its value.

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


Correct Option: C
Explanation:

This interface in event listener interface defines one method to recognize when a text value changes.

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


Correct Option: B
Explanation:

This terminology in FontMetrics class defines the distance from the baseline to the top of a character.

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


Correct Option: D
Explanation:

This method of Font class returns the name of the font family to which the invoking font belongs.

Classes Http Servlet and Generic Servlet implement the ________ interface.

  1. Rmi

  2. Corba

  3. Jdbc

  4. Servlet


Correct Option: D

The life cycle of a Servlet is

  1. init, start, stop

  2. init, begin, stop, destroy

  3. init, service, destroy

  4. none of these


Correct Option: C

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


Correct Option: B
Explanation:

getItemSelectable() method can be used to obtain a reference to the ItemSelectable object that generate an event.

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

  1. Focus Event

  2. Keyboard Event

  3. Text Event

  4. Mouse Event


Correct Option: A
Explanation:

FocusEvent is generated when a component gains or loses input focus.

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


Correct Option: A
Explanation:

Java Programming language provide Adapter classes that implement the corresponding listener interface containing more than one method.

A connection object is initialized using the ___________ method.

  1. getConnection()

  2. createStatement()

  3. executeQuery()

  4. getQuery()


Correct Option: A
Explanation:

The connection object is initialized using the getConnection() method.

______________ 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


Correct Option: C
Explanation:

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

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

  1. translatePoint()

  2. getClickCount()

  3. isPopupTrigger()

  4. getitem()


Correct Option: B
Explanation:

getClickCount() method of MouseEvent obtains the number of mouse clicks for the event

- Hide questions