0% found this document useful (0 votes)
20 views

Tutorial 2

Advance java programming mcq for msbte exam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Tutorial 2

Advance java programming mcq for msbte exam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Tutorial 2

1.Which package is used for Swing components in Java?


a) java.awt b) javax.swing c) java.util d) java.io

2.Which Swing component is used to create a button?


a) JLabel b) JRadioButton. c) JButton d) JTextArea

3.Which Swing component is used to display a list of items with a


single selection?
a) JComboBox b) Jlist c) JTable d) JCheckBox

4.Which Swing component is used to create a tabbed pane?


a) JTabbedPane b) JTabComponent c) JTabView. d) JTabControl

5.Which method is used to set the text of a JLabel in Swing?


a) setText() b) setTextLabel() c) setLabel() d) setTextValue()

6.How do you make a Swing component visible on the screen?


a) setVisible(true) method. b) show() method c) display() method. d)
open() method

7.How do you add components to a JFrame in Swing?


a) addComponent() method b) append() method c) insertComponent()
method d) add() method

8.Which class is used to create a check box in Swing?


a) JCheckBox b) JRadioButton c) JToggleButton d) JCheckButton

9.How do you set the size of a JFrame in Swing?


a) setSize() b) setDimension() c) setWidthHeight() d) setBounds()

10.Which class is used to display an image in Swing?


a) ImageDisplay b) ImageViewer. c) ImageIcon d) ImagePanel
11.Which component is used to display a tooltip when the mouse
hovers over it?
a) JToolTip b) JPopup. c) JTooltipPane d) JPopupTip

12.The Components in JApplet are added to


a) Current JApplet Class b)ContentPane. c)Both A and B d) None

13.How many Options can be selected in JRadioButton at a time?


a) Only One b) Multiple c)It is defined in the program d)Only a
maximum of six

14.A tree represent a __________ view of data.


a) Structural. b)Hierchical c)Multiple d) Single

15.Which of the following alignment is not possible for JLabel ?


a) TOP. b) LEFT c) CENTER d) LEADING

16.MVC stands for ____


a) Model Version Control. b) Model View Controller.
c)Mini View Controller. d)Major View Controller.

17.What is the purpose of JTree?


a). To show data in the form of parent and child nodes. b). To show data
in list view .
c)To show data in tabular form. d). To show data in menu-bar .

18.Which of the following architecture does the swing framework


use ?
a) MVC b) MVP c) Layered Architecture d) Master-slave Architecture

19.Which of these methods cannot be called on JLAbel object?


a)setIcon() b)getText() c)setLabel() d)setBorderLayout()

20.Swing components are ______________ .


a)Platform dependent b)Platform independent c)Both A & B d)Platform
oriented

21.What is the return type of getText() method of JButton class?


a)Void b)String c)Character Array d)There is no such metho

22.Default Orientation of progress bar is _________________ .


a)Horizontal b)Vertical c)Both A and B d)None of these

23.JTabbedPane class is present in which packages?


a)Java.awt.*; b)Javax.swing.*; c)Java.io.*; d)Java.util.*;

24.Swing is based on ______________ architecture.


a)Client Server b)Model View Controller c)Layered d)None of these

25.In swing, Buttons are subclasses of which class?


a) AbstractButton b) JButton c) Button d) JRadioButton

26.Which component is swing represents data in row and columns?


a) JTextArea b) JTable c) JPanel d) JtabbedPane

27.___________class used to create node in tree.


a) TreeNode b) DefaultMutableNode c) DefaultMutableTreeNode d)
Node

28.Which of the following method is not applicable for Button in


swing.
a) setDiableIcon() b) setPressedIcon() c) setSelectedIcon() d)
setRollOverIcon()

29.From following list which is not Swing class?


a) JLabel b) JButton c) JImageIcon d) JCheckBox

30.In Swing, the content pane can be obtained via the method:
a) getContentPane() b) fetchContentPane() c) retrieveContent() d)
accessContent()

31.In Swing, what component is used for adding hints to other


Swing components to provide additional information?
A. JToolTip B. JLabel C. JTextField D. JTabbedPane

32.Which is the Swing check box class.


a) JCheckbox b) JSCheckbox c) JCheckBox d) None

33.Which event is generated when a JButton is pushed?


a) ItemEvent b) TextEvent c) PushEvent d) ActionEvent

34.How can we create Radio buttons in Swing?


a) Using ButtonGroup class b) Using JCheckboxGroup class c) Using
JRadioButton class d) Using JButton class

35.Which of the following constants shows scroll bars always?


a) HORIZONTAL_SCROLLBAR_ALWAYS b)
HORIZONTAL_SCROLLBAR_AS_NEEDED c)
HORIZONTAL_SCROLLBARS
d) HORIZONTAL_ALWAYS

36.Tabs are added by calling


a) getTab() b) setTab() c) addTab() d) all of these

37.What will be the correct statement if you want a checkbox to be


checked by default?
a) JCheckBox jc= new JCheckBox(String s, boolean checked)
b) JCheckBox jc= new JCheckBox(String s, boolean false)
c) JCheckBox jc= new JCheckBox(String s, boolean unchecked)
d) JCheckBox jc= new JCheckBox(String s, boolean true)

38.Which is the correct syntax for constructor of JRadioButton?


a) JRadioButton(Icon i, String s, boolean state)
b) JRadioButton(String s, Icon i, boolean state)
c) JRadioButton(Icon i,boolean state, String s, )
d) d)JRadioButton(boolean state, String s, Icon i)

39.The _____________ determines how the component reacts to the


user
a) View b) Controller c) User d) Model

40.Identify The Error :


import javax.swing.*;
public class FirstSwingExample{
public static void main(String[] args) {
JFrame f=new JFrame();
JButton b=new JButton("click");
b.setBounds(130,100,100, 40)
f.add(b);
f.setSize(400,500);
f.setLayout(null);
}}
A) No Error B) Set Visible Method is not defined C) Button is not added
on Frame D) inside main method error

You might also like