MCQ Answers Updated

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

MCQ Answers

1. 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: CheckboxMenuItem

2. Which of these method interfaces define a method `actionPerformed()`?

a. ComponentListener

B .ContenerListener

c. ActionListener

d. InputListener

Answer: ActionListener

3. Which is/are used to create a Frame?

i By creating the object of Frame Class(association)

ii. By extending Frame class (inheritance)

a.Only i

b.Only ii

c. Both

d. None of Above
Answer: Both

4. Which of the following sets the frame, say frame, to 300 pixels wide by 200 high?

a. f.setSize( 300, 200 );

b. f.setSize( 200,300 );

c. f.paint( 300, 200 );

d. None of these

Answer: f.setSize(300, 200)

5. ______ class used to create a node in a tree

a. TreeNode

b. Default Mutable Node

c. Default Mutable Tree Node

d.None

Answer: DefaultMutableTreeNode

6. Which of the following is true about applet?

a.Applet Do not have a main() method.

b.Applet must run under Appletviewer.

c.The user I/O is not performed using java stream I/O class.

d.All of the Above

Answer: All of the Above


7. Which of the following packages supports the event handling routine when using Swing
components in GUI programs?

a. javax.swing

b. java.awt

c. java.util

d. java.applet

Answer: javax.swing

8. The following: a) It is lightweight. b) It supports pluggable look and feel. c) It follows MVC
(Model View Controller) architecture are the advantages of _____.

a. Swing

b. AWT

c.ActionEvent

d. None of above

Answer: Swing

9. Which of the following is/are not related to keyboard events?

a. ClassKeyEvent is used to notify if any key pressed occurs or not.

b. The KeyListener should be added either in init() or the main method

c. RequestFocus should be added either in init() or the main method.

d. The class InputEvent should be imported explicitly in the program

Answer: The KeyListener should be added either in init() or the main method
10. The MouseListener interface specifies the following methods: mouseClicked,
mouseEntered, mouseExited, mousePressed, and mouseReleased. In order to use a
MouseListener in your code, you must provide an implementation for which of the
following?

a) None of the MouseListener methods

b) All MouseListener methods.

c) At least the mouseClicked method

d) Any one MouseListener method

Answer: All MouseListener methods

11. The ActionListener interface is not used for handling action events.

a) True

b) False

Answer: False

12. Which Method of the component class is used to set the position and size of the
component?

a. setPosition

b.setBounds

c.setSize

d.none of above

Answer: setBounds
13. In Swing ____ Gives Visual Representation of the Component

a. Model

b.View

c.Controller

d.none of above

Answer: View

14. What does the following line of code do? TextField text = new TextField(20);

a.Creates a text object that can hold 20 rows of text.

b. Creates a text object that can hold 20 columns of text.

c. Creates object text and initializes it with the value 20.

d.Invalid Code

Answer: Creates a text object that can hold 20 columns of text

15. Using a FlowLayout manager, which is the correct way to add elements to a container?

a) add (component);

b) add(“Center”, component);

b) add(x, y, component);

d) set(component);

Answer: add(component)

16. How Many Controls in AWT

Answer: AWT controls include elements like Buttons, Labels, Checkboxes, etc.
16. Which of these method interfaces define a method `itemStateChanged()`?

a. ComponentListener

b.ContenerListener

c.ActionListener

d.ItemListener

Answer: ItemListener

17. The Difference between ScrollBar and ScrollPane is ____.

a.ScollBar is a component and ScrollPane is Container.

b. ScrollBar is a Container and ScrollPane is a component.

c. ScollBar and ScrollPane both are components.

d.ScollBar and ScrollPane both are Containers

Answer: ScrollBar is a component, and ScrollPane is a Container

18. Which of these events is generated by scrollbar?

a.ActionEvent b.KeyEvent

c.WindowEvent d.AdjustmentEvent

Answer: AdjustmentEvent

19. Which of these methods will be invoked if a character is entered?

a.keyPressed() b.keyReleased()

c.keyTyped() d.keyEntered()
Answer: keyTyped()

21. At the top of the AWT hierarchy is the__________________ class.

Answer: Component

22. AWT classes are contained in the __________ package

Answer: java.awt

23. AWT is used for creating a GUI in Java. AWT stands for

Answer: Abstract Window Toolkit

24. AWTEvent Class is defined in the following package

Answer: java.awt

You might also like