Alien head

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

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

Answer: 2
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

Answer: 3
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.

Answer: 2
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

Answer: 4
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

Answer: 3
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

Answer: 2
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()

Answer: 4
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

Answer: 4

The life cycle of a Servlet is

  1. init, start, stop

  2. init, begin, stop, destroy

  3. init, service, destroy

  4. none of these

Answer: 3

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

Answer: 2
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

Answer: 1
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

Answer: 1
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()

Answer: 1
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

Answer: 3
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()

Answer: 2
Explanation:

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

+ View questions