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

Unit 2 Swing

Unit 2 swing
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Unit 2 Swing

Unit 2 swing
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

: Q.1 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: a

Q. 2 Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?

(a) True (b) False

Answer:b

Q.3 The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons?

(a) AbstractButton

(b) ButtonGroup

(c) JButton

(d) Imagelcon

Answer: b

Q. 4 The Java Foundation Classes (JF(c) is a set of GUI components which simplify the development of
desktop applications?

(a) True (b) False

Answer: a

Q. 6 The String parameter to JButton constructor

(a) tell which region to put the JButton in,

(b) tells the color of the JButton.

(c) tells what text will appear on JButton.

(d) tells what should happen when JButton is pressed,


Answer: c

Q.7 MVC architecture is

(a) Modelling-Visual-Controller

(b) Model-View-Controller

(c) Model-Viewable-Controller

(d) Many-View-Controller

Answer: b

Q. 8 Alignment constants of JLabel are the part of

a) SwingConstants interface

b) SwingConstants class

c) Swing class

d) Graphics dass

Answer: a

Q.9 In swing, Buttons are subclasses of which class?

(a) AbstractButton

(b) JButton

(c) Button

(d) JRadioButton

Answer: a

Q10 JTree class belongs to which package?

(a) java.awt

(b) java.applet

(c) java.swing

(d) javax.swing

Answer: d
Q. 11 Which component is swing represents data in row and columns?

(a) JTextArea

(b) JTable

(c) JPanel

(d) JtabbedPane

Answer: b

Q. 12 Which of the following is not constructor of JTree?

(a) JTree(TreeNode tnj

(b) JTree(Vector v)

( c) JTree(int x)

(d) none of the above

Answer: c

Q.13class used to create node in Jtree.

(a) TreeNode

(b) Default MutableNode

(c) Default Mutable TreeNode

(d) Node

Answer: c

Q. 14 JTabbedPane class is present in which package?

(a) java.awt (bljava.swing

(c) java.awt.swing

(d) javax.swing

Answer: d

Q. 15 What is purpose of JTree?

(a) To show data in form of parent and child nodes.


(b) To show data in Ist view,

(c) To show data in tabular form.

(d) To show data in menu-bar,

Answer: a

Q. 16 What is the use of Container DenCenterPane

(a) Retums Container for a JDialog.

(b) Retums a ContentPane for Menu

(c) Retums a ContentPane for Applet

d) None of the above

Answer: c

Q. 17. Which of the following method is not applicable for Button in swing.

(a) setDiablelicon() (b) setPressedicon)

(c) setSelectedicon (d) setRollOvedcon

Answer: c

Q. 18 Which of the following method is used to retrieve icon of JButton?

( a) Icon geticon()

(b) Imageloon

(c) Imagelcon geticon()

(d) Imagelcon Gettmagelicon()

Answer: c

Q. 19. Which method is used to display icon on a Button?

a)setimage(Imagelcon

b) seticon Intagelcon i

c)setPicture(ImageIcon()

d) settimagelcon Imagelcon ()
Answer: b

Q. 20. How will you set icon for the Jlabel?

a) Using Icon class directly

b) Using seticon() method

c) Using makelcon() method

d) It is not possible to set icon for JLabel

Answer: b

Q. 22. The constructor JCheckBox(true, "YES") suggests that

a) Checkbox is sellected and displays the string "YES" on it

b) Checkbox is deselected and displays the string "YES" on it.

c) Checkbox is selected and it shows the tick always on it.

d) There is no such constructor

Answer: d

Explanation: No explanation Available

Q. 23. How to make the group of Radio buttons?

a) Using ButtonGroup class

b) Using JButtonGroup class

c) Using JRadioButton

d) Using AbstractButton class

Answer: a

Q. 24. How to contents of whole vector into the JComboBox?

a) Use the constructor of JComboBox


b) Use method additem()

c) Use method addVector()


d) Use method addValues()

Answer: a

Q. 25. The scroll bar constants for scroll pane are defined in _ a) Scrollbar class ZEAL POLYTECKNIG

b) ScrollPane dass

c) ScrollPaneConstants interface

Component class Answer: c

Q. 26. Which of the following constants shows scroll bars always?

A)HORIZONTAL SCROLLBAR ALWAYS

B)) HORIZONTAL SCROLLBAR AS_NEEDED

C)HORIZONTAL SCROLLBARS

D) HORIZONTAL ALWAYS

Answer: a

Q. 27. Is it possible to add array of objects to trees? How?

a) Not possible

b) Yes, using its one of the forms of constructor

c) Yes, using the add() method

d) Yes, using the addite additem() method

Answer: b

Q. 28. Find an error of following program

import javax.swing.JFrame:

import javax.swing.JTree
import javax.swing.SwingUtilities: import

javax.swing.tree, DefauMutable TreeNode: public class TreeExample extends JApplet

(JTree tree

public void init

DefaultMutabile TreeNode root =new DefaultMutable TreeNode("Root");

DefaultMutable TreeNode vegetableNode=NEWDefaultMutable TreeNode("Vegetables");

Default Mutable TreeNode fruitNode=new Default Mutable TreeNode("Fruits");

root.add(vegetableNode):

root.add(fruitNode);

tree new JTree();

add(tree); }}

<applet code "TreeExample" width=300 height=300

</applet>/

a) Error in statement in which JTree is created

b) Error in Applet code

C)No error

d) Error in Frame

Answer: в

Q. 29. Identify missing statemeAL POLYTECHNIC

import java.awt.

import java.applet;

import javax.swing.

public class Combo extends


JApplet public void int() { Container c=getContentPane();

JComboBox jornew JComboBox() jc.additem("AJP"

STE jc.addhem("AMI"): jc.addtem("EDP");

jc.additem"

<applet code "Combo.class" height=200 width=200></applet

a) Addljc),

b) Jc.add(c);

c)c.add(jc)

d) Add(c)

Answer: c

Q. 30. The default orientation to display the progress bar is?

HORIZONTAL

Answer: c

Q. 31, Mutable TreeNode is extends

a) TreePath

by TreeNode

Defaul Mutable TreeNode

d) Mutable TreeNode

Answer: b

interface

Q. 32, Which two parameters are required for JTree constructor to create a free?

a) Data array and Row Headings

bi Data array and Column Headings

c) Single data element and Column heading


d) Single data element and Row heading

Answer: b

Q. 33. How to create for Vector elements?

aj Pass vector as parameter for JTree

b) Use method addElements() for JTree class.

c) Use method addVector() method of JComponent class

d) It is not possible

You might also like