100% found this document useful (1 vote)
458 views

Java MCQ

This document contains 67 multiple choice questions about Java concepts including AWT, Swing, events, and GUI components. The questions cover topics such as commonly used AWT methods, event handling interfaces and methods, AWT vs Swing components, layout managers, look and feels, and dialogs.

Uploaded by

Diri Caf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
458 views

Java MCQ

This document contains 67 multiple choice questions about Java concepts including AWT, Swing, events, and GUI components. The questions cover topics such as commonly used AWT methods, event handling interfaces and methods, AWT vs Swing components, layout managers, look and feels, and dialogs.

Uploaded by

Diri Caf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

JAVA MCQ

1) Where are the following four methods commonly used?


1) public void add(Component c)
2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)

a. Graphics class
b. Component class
c. Both A & B
d. None of the above

2) Implement the Listener interface and overrides its methods is required to perform
in event handling.
a. True
b. False

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

4) These two ways are used to create a Frame

By creating the object of Frame class (association)


By extending Frame class (inheritance)
a. True
b. False

5) Give the abbreviation of AWT?


a. Applet Windowing Toolkit
b. Abstract Windowing Toolkit
c. Absolute Windowing Toolkit
d. None of the above

6) Which method is used to set the graphics current color to the specified color in
the graphics class?
a. public abstract void setFont(Font font)
b. public abstract void setColor(Color c)
c. public abstract void drawString(String str, int x, int y)
d. None of the above

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

a. True
b. False
8) 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)

9) Which object can be constructed to show any number of choices in the visible
window?
a. Labels
b. Choice
c. List
d. Checkbox

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

11) Which class is used for this Processing Method processActionEvent( )?


a. Button,List,MenuItem
b. Button,Checkbox,Choice
c. Scrollbar,Component,Button
d. None of the above

12) Which method can set or change the text in a Label?


a. setText()
b. getText()
c. All the above
d. None of the above

13) Which is a component in AWT that can contain another components like buttons,
textfields, labels etc.?
a. Window
b. Container
c. Panel
d. Frame

14) AWT has more powerful components like tables, lists, scroll panes, color
chooser, tabbed pane etc.
a. True
b. False

15) Which are passive controls that do not support any interaction with the user?
a. Choice
b. List
c. Labels
d. Checkbox
16) How many types of controls does AWT support?
a. 7
b. 6
c. 5
d. 8

17) 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. Both A & B
d. None of the above

18) The ActionListener interface is not used for handling action events.
a. True
b. False

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

20) Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI
application
a. True
b. False

21) The Following steps are required to perform


1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener
a. Exception Handling
b. String Handling
c. Event Handling
d. None of the above

22) Where can the event handling code be written?


a. Same class
b. Other class
c. Anonymous class
d. All mentioned above

23) Which class provides many methods for graphics programming?


a. java.awt
b. java.Graphics
c. java.awt.Graphics
d. None of the above
24) AWT is used for GUI programming in java
a. True
b. False

25) The ActionListener interface is not used for handling action events
a. True
b. False

26) The Swing Component classes that are used in Encapsulates a mutually exclusive
set of buttons?
a. AbstractButton
b. ButtonGroup
c. JButton
d. ImageIcon

27) AWT components are


a. Platform dependent
b. Platform Independent
c. Both A & B
d. None of Above

28) AWT components are


a. lightweight
b. heavyweight
c. equalweight
d. None of Above.

29) AWT components are available in


a. java.util package
b. java.io package
c. javax.awt package
d. java.awt package

30) The size of a frame on the screen is measured in ______.


a. Inches
b. Dots
c. Nits
d. Pixels

31) setBackground() method to set the background color for ____?


a. Component
b. Container
c. JComponent
d. None of Above

32) What does the following line of code do?


Textfield text = new Textfield(10);
a. Creates the object TextField and initializes it with the value 10.
b. Creates TextField object that can hold 10 rows of text.
c. Creates TextField object that can hold 10 columns of text.
d. All of Aboves
33) Which statement creates a Text Area with 10 rows and 20 columns?
a. TextArea text = new TextArea(10,20);
b. TextArea text = new TextArea(20,10);
c. TextArea text = new TextArea(200);
d. None of Above

34) To make dropdown menu of choice which component is used in AWT?


a. List
b. Combobox
c. Checkbox
d. Choice

35) User can edit information displayed in Label at runtime.


a. True
b. False

36) How many line input takes from user in Text Field in AWT.
a. 3
b. 2
c. 1
d. None of Above

37) Using which component user can implement radiobutton in AWT?


a. Checkbox with CheckboxGroup
b. Only Checkbox
c. RadioButton
d. JRadioButton

38) Which abstract class is the super class of all menu related classes?
a. MenuBar
b. CheckboxMenuItem
c. MenuItem
d. MenuComponent

39) Which can be used to represent a checkbox with a textual label that can appear in
a menu?
a. MenuBar
b. Menu
c. CheckboxMenuItem
d. MenuItem

40) Layout manager is used to


a. Add component to Layout
b. Arrage components in particular manner
c. Both A & B
d. None of Above

41) Swing have more components than AWT.


a. True
b. False
42) Which of the following class is super class that declares common features of GUI
components in packages java.awt and javax.swing?
a. Container
b. Frame
c. Component
d. Panel

43) What is fullform of JFC?


a. Java Functions Collections
b. Javax Foundation Class
c. Java Foundation Classes
d. None of Above

44) Swing components are


a. Platform dependent
b. Platform Independent
c. Both A & B
d. None of Above

45) Which of the following is not layout manager?


a. FlowLayout
b. GridLayout
c. CardLayout
d. None of Above

Which layout is used for the container has a row of components that should all be
displayed at the same size, filling the container entire area?
a. FlowLayout
b. GridLayout
c. CardLayout
d. None of Above

46) In which layout only one component visible at a time?


a. FlowLayout
b. GridLayout
c. BorderLayout
d. CardLayout

47) Which layout is used to arrage components in a line left to right on after another?
a. FlowLayout
b. GridLayout
c. BorderLayout
d. CardLayout

48) In which layout NORTH, SOUTH, EAST, WEST regions available?


a. FlowLayout
b. GridLayout
c. BorderLayout
d. CardLayout
50) Which package needs to import to implement swing program?
a. javax.swing
b. java.swing
c. java.awt
d. None of Above

51) Which of the following is not type of look & feel?


a. Metal Look & Feel
b. Motif Look & Feel
c. Motive Look & Feel
d. Windows Look & Feel

52) Which of following class is used to implement frame in swing?


a. Jwindow
b. JFrame
c. Frame
d. SwingFrame

53) Which class is used to implement radiobutton using swing?


a. RadioButton
b. JCheckBox with CheckboxGroup
c. JRadioButton
d. None of Above

54) Which class is used to implement dropdown using swing?


a. Jlist
b. JRadioButton
c. ComboBox
d. JComboBox

55) Which of following is correct?


a. JTextComponent extens JTextArea
b. JTextArea extens JTextField
c. JTextField extens JTextComponent
d. JTextComponent extens JTextField

56) Which inbuilt dialog allows user to select file?


a. JFileInputChooser
b. JFileChooser
c. JFileSelector
d. JFileInputSelector

57) Which of following is correct statement?


a. A dialog can have menubar
b. JMenuItem extends Jmenu
c. Menu item can be added to menu
d. All of Above
58) _________ component provides to show various dialog such as error, user
specific message, confirmation etc.
a. JDialogBox
b. JFileChooser
c. Jtable
d. JOptionPane

59) Which of following control is available in swing but not in AWT?


a. Button
b. Label
c. RadioButton
d. CheckBox

60) The Swing Component classes that are used in Encapsulates a mutually exclusive
set of buttons?
a. ButtonGroup
b. JButton
c. AbstractButton
d. ImageIcon

61) Which of these is superclass of all Adapter classes?


a. Event
b. Applet
c. ComponentEvent
d. InputEvent

62) Which class is super class of all the events?


a. EventObject
b. EventClass
c. ActionEvent
d. ItemEvent

63) Which of following interface define a method itemStateChanged()?


a. ActionListener
b. ItemListener
c. MouseListener
d. ComponentListener

64) Which of following interfaces define a method actionPerformed()?


a. ContainerListener
b. ItemListener
c. ActionListener
d. MouseListener

65) Which of following method will respond when we click by mouse in frame?
a. mousePressed()
b. mouseEntered()
c. mouseClicked()
d. All of Above
66) Which of following method will be invoked if a character is entered from
keyboard?
a. keyTyped()
b. keyPressed()
c. keyReleased()
d. keyEntered()

67) Which of following method is defined in MouseMotionAdapter class?


a. mousePressed()
b. mouseClicked()
c. mouseDragged()
d. mouseReleased()

68) Which event will be notified if scroll bar is manipulated?


a. AdjustmentEvent
b. WindowEvent
c. ComponentEvent
d. ActionEvent

69) Which method is used to register a keyboard event listener?


a. KeyListener()
b. addKeyListener()
c. eventKeyboardListener()
d. None of Above

70) Which of the methods are used to register a mouse motion listener?
a. addMouse()
b. addMouseListener()
c. addMouseMotionListner()
d. None of Above

71) Which package needs to import for hadlining event?


a. Java.Applet
b. Java.awt.event
c. Java.event
d. None of Above

72) Which of following event generate when button is pressed?


a. WindowEvent
b. ActionEvent
c. PressEvent
d. ButtonEvent

73) Which of following event generate when checkbox is clicked?


a. CheckBoxEvent
b. ItemPressEvent
c. ItemEvent
d. ClickEvent
74) Which of following event generate when input received from keyboard?
a. KeyEvent
b. KeyBoardEvent
c. KeyPressedEvent
d. None of Above

75) Which swing component is source of ItemEvent?


a. JPopupMenu
b. Jlabel
c. JTextField
d. JComboBox

76) Which of following is/are constants defined in WindowEvent class?


a. WINDOW_ACTIVATED
b. WINDOW_CLOSED
c. WINDOW_DEICONIFIED
d. All of Above

77) What is an event in delegation event model used by Java programming language?
a. An event is an object that describes a state change in a source
b. An event is an object that describes a state change in processing
c. An event is an object that describes any change by the user and system
d. An event is a class used for defining object, to create events

78) What is a listener in context to event handling?


a. A listener is a variable that is notified when an event occurs
b. A listener is a object that is notified when an event occurs
c. A listener is a method that is notified when an event occurs
d. None of the mentioned

79) Event class is defined in which of these libraries?


a. java.io
b. java.lang
c. java.net
d. java.util

80) Which of these methods can be used to determine the type of event?
a. getID()
b. getSource()
c. getEvent()
d. getEventObject()

81) Which of these events will be generated if we close an applet’s window?


a. ActionEvent
b. ComponentEvent
c. AdjustmentEvent
d. WindowEvent

You might also like