Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

1.

Which is the container that doesn't contain title bar and MenuBars but it can
have other components like button, textfield etc?
• A. Window
• B. Frame
• C. Panel
• D. Container

Answer: Option C

2. The Swing Component classes that are used in Encapsulates a mutually


exclusive set of buttons?

• A. AbstractButton
• B. ButtonGroup
• C. JButton
• D. ImageIcon

Answer: Option B

3. Which package provides many event classes and Listener interfaces for event
handling?

• A. java.awt
• B. java.awt.Graphics
• C. java.awt.event
• D. None of the above

Answer: Option C

4. In Graphics class which method is used to draws a rectangle with the specified
width and height?

• A. public void drawRect(int x, int y, int width, int height)


• B. public abstract void fillRect(int x, int y, int width, int height)
• C. public abstract void drawLine(int x1, int y1, int x2, int y2)
• D. public abstract void drawOval(int x, int y, int width, int height)

Answer: Option A
5. Name the class used to represent a GUI application window, which is optionally
resizable and can have a title bar, an icon, and menus.

• A. Window
• B. Panel
• C. Dialog
• D. Frame

Answer: Option D

6. To use the ActionListener interface it must be implemented by a class there are


several ways to do that find in the following?

• A. Creating a new class


• B. Using the class the graphical component
• C. An anonymous inner class
• D. All mentioned above

Answer: Option D

7. Which is a component in AWT that can contain another component like buttons,
text fields, labels etc.?

• A. Window
• B. Container
• C. Panel
• D. Frame
Answer: Option B

8. Which is used to store data and partial results, as well as to perform dynamic
linking, return values for methods, and dispatch exceptions?

• A. Window
• B. Panel
• C. Frame
• D. Container

Answer: Option C

9. What are the different types of controls in AWT?

• A. Labels
• B. Pushbuttons
• C. Checkboxes
• D. Choice lists
• E. All of these

Answer: Option E

10. Give the abbreviation of AWT?

• A. Applet Windowing Toolkit


• B. Abstract Windowing Toolkit
• C. Absolute Windowing Toolkit
• D. None of the above

Answer: Option B

11. Which class provides many methods for graphics programming?

• A. java.awt
• B. java.Graphics
• C. java.awt.Graphics
• D. None of the above

Answer: Option C

12. By which method You can set or change the text in a Label?

• A. setText()
• B. getText()
• C. Both A & B
• D. None of the above

Answer: Option A

13. Which class can be used to represent a checkbox with a textual label that can
appear in a menu.

• A. MenuBar
• B. MenuItem
• C. CheckboxMenuItem
• D. Menu

Answer: Option C

14. The following specifies the advantages of It is lightweight. It supports


pluggable look and feel. It follows MVC (Model View Controller) architecture.

• A. Swing
• B. AWT
• C. Both A & B
• D. None of the above
Answer: Option A

15. The Java Foundation Classes (JFC) is a set of GUI components which simplify
the development of desktop applications?

• A. True
• B. False
• C. All of these
• D. None

Answer: Option A

16. How many types of controls does AWT supports these controls are subclasses
of component?

• A. 7
• B. 6
• C. 5
• D. 8

Answer: Option A

17. Which are passive controls that do not support any interaction with the user?

• A. Choice
• B. List
• C. Labels
• D. Checkbox

Answer: Option C

18. How many ways can we align the label in a container?

• A. 1
• B. 2
• C. 3
• D. 4

Answer: Option C

19. The following way is used to create a frame is by creating the object of Frame
class?

• A. inheritance
• B. association
• C. Both A & B
• D. None of the above

Answer: Option B

20. Which of the following classes are derived from the Component class.

• A. Container
• B. Window
• C. List
• D. MenuItem

Answer: Option D

21. AWT stands for ?

A. All Window Toolkit


B. Abstract Work Toolkit
C. Abstract Window Toolkit
D. Abstract Window Text

Ans : C
Explanation: AWT stands for Abstract Window Toolkit and infact it is a package –
java.awt. The classes of this package give the power of creating a GUI
environment to the programmer in Java.

22. The subclass of a java.awt.Component class is known as a ?

A. system
B. component
C. container
D. component manager
Ans : B

Explanation: By definition, the subclass of a java.awt.Component class is known


as a component.

23. What is the super class of all components of Java?

A. java.all.Component
B. all.awt.Component
C. java.awt.Component
D. awt.Component
Ans : C

Explanation: It is java.awt.Component.

24. The subclass of a java.awt.Container class is known as a container.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
Ans : A

Explanation: True, the subclass of a java.awt.Container class is known as a


container.
25. How many layout managers defined in java.awt package?

A. 2
B. 3
C. 4
D. 5
Ans : D

Explanation: There are 5 layout managers defined in java.awt package –


FlowLayout, BorderLayout, GridLayout, CardLayout and GridBagLayout.

26. A ___________ dictates the style of arranging the components in a container.

A. border layout
B. grid layout
C. panel
D. layout manager
Ans : D

Explanation: A layout manager dictates the style of arranging the components in a


container.

27. Which method used to place some text in the text field?

A. getText(String str)
B. setText(String str)
C. putText(String str)
D. None of the above
Ans : B

Explanation: setText(String str) method of TextField class.


28. What is the listener used to handle the events of a text field?

A. java.awt.ActionListener interface
B. java.awt.event.ActionListener
C. awt.event.ActionListener interface
D. java.awt.event.ActionListener interface
Ans : D

Explanation: java.awt.event.ActionListener interface used to handle the events of a


text field.

29. Which method used to change the foreground (text) color of components like
text field?

A. setBackground(Color clr)
B. setForeground(Color clr)
C. setColor(Color clr)
D. setEditable(boolean state)
Ans : B

Explanation: setForeground(Color clr) of java.awt.Component class.

30. getLabel() method used to retrieve the label of a button.

A. Yes
B. No
C. Can be yes or no
D. Can not say
Ans : A

Explanation: getLabel() method used to retrieve the label of a button.

31. Which of the following classes in Java contains swing version of an applet?
1. JButton
2. JCheckBox
3. JApplet
4. AbstractButton
5. JLabel

Correct Option: C

Explanation:

This class in java contains swing version of applet.


32. Which of the following statements is must in a Java program for creating a
frame?
1. import java.awt.*;
2. import java.awt.event.*;
3. import java.awt.frame;
4. 1, 2 and 3
5. only 1 and 2

Correct Option: D

Explanation:

Option 3 is also required. This option is correct.


33. Which of the following align arguments is not available in Java to be used in
SwingConstants interface?
1. Left
2. Right
3. Middle
4. Leading
5. Trailing
Correct Option: C

Explanation:

This align argument is not available in Java to be used in SwingConstants


interface.
34. Which of the following classes of Java swing extends Applet class?
1. JButton
2. JApplet
3. AbstractButton
4. None of these

Correct Option: B

Explanation:

This class of Java swing extends Applet class.


35. In Java swing, which of the following components is/are represented by a
rectangular area in which a component may be viewed?
1. Scroll pane
2. Tabbed pane
3. Combo boxes
4. None of these

Correct Option: A

Explanation:
This component in Java swing is represented by a rectangular area in which a
component may be viewed.
36. Which of the following classes in java.awt package describes a graphics
device such as a screen or printer?
1. Canvas
2. GraphicsDevice
3. Frame
4. None of these

Correct Option: B

Explanation:

This class in java.awt package describes a graphics device such as a screen or


printer.
37. What is not true for a Java bean?
1. There are no public instance variables.
2. All persistent values are accessed using getxxx and setxxx methods.
3. It may have many constructors as necessary.
4. All of the above are true of a Java bean.

Correct Option: C

38. What is invoked via HTTP on the Web server computer when it responds to
requests from a user's Web browser?
1. A Java application
2. A Java applet
3. A Java servlet
4. None of these
Correct Option: C

39. Which component of an event is the object that generates the event?
1. Event object
2. Event source
3. Event handler
4. None of these

Correct Option: B

Explanation:

Event source is an object that generates an event.


40. _________ is generated when a button is pressed, a list item is double-clicked
or a menu item is selected.
1. Action Event
2. Adjustment Event
3. Component Event
4. Container Event

Correct Option: A

Explanation:

Action Event is generated when a button is pressed, a list item is double-clicked or


a menu item is selected.
41. Which of the following events is generated when the size, position or
visibility of a component is changed?
1. Adjustment Event
2. Component Event
3. Container Event
4. Item Event

Correct Option: B

Explanation:

Component Event is generated when the size, position or visibility of a component


is changed.
42. To create swing components, which of the following is imported?
1. javax.awt.*
2. java.awt.*
3. javax.swing.*
4. java.swing.*

Correct Option: C

43. Which event is generated when a checkbox or a list item is clicked or when a
check menu item is selected or deselected?
1. Container Event
2. Component Event
3. Focus Event
4. Item Event

Correct Option: D

Explanation:
Item Event is generated when a check box or a item list is clicked or when a check
menu item is selected or deselected.
44. Swing elements are preceded by the letter
1. S
2. A
3. X
4. J

Correct Option: D

45. Which of the following user interfaces defines how should components be
arranged in a container?
1. Component
2. Container
3. Layout manager
4. None of these

Correct Option: C

Explanation:

Layout manager defines how the components will be arranged in a container.


Which of the following is the default Layout Manager for an Applet?
(a) FlowLayout
(b) BorderLayout
(c) GridLayout
(d) CardLayout
(e) MarginLayout.
Ans:- a

You might also like