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

AJP Chapter 2 Answer

Uploaded by

Neha Kolambe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

AJP Chapter 2 Answer

Uploaded by

Neha Kolambe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CHAPTER-2 (Swings) (CO1 And CO2)

Q.1 Pluggable look and feel and lightweight components are the features supported by ____.
a) Swing b) AWT
c) Core Java d) None of these

--- a) Swing

Q.2 Swing is based on ________ architecture.


a) Client server b) model view controller
c) Layered d) None of these

--- b) model view controller

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

--- b) False

Q.4 The Java Foundation Classes (JFC) is a set of GUI components which simplify the
development of desktop applications
a) True b) False

--- a) True

Q.5 Following letter used as a prefix to swing component.


a) A b) S
c) G d) J

--- d) J

Q.6 _______ is one of the features of object oriented programming that allows creation of
hierarchical classifications.
a) Polymorphism b) Class
c) Inheritance d) Object

--- c) Inheritance

Q.7 In swing JButton class is derived from ______.


a) Abstract Button b) JToggleButton
c) JComponent d) None of these

--- c) JComponent

Q.8 The JTextComponent derives two components JTextField and _______.


a) JComboBox b) JTextArea
c) JSlider d) All of the above

--- b) JTextArea
Q.9 In swing class hierarchy the class present at the root is ______.
a) Component b) Window
c) Container d) Object
---a) Component
Q.10 ________ pane can be used to add component to container.
a) Glass b) Content
c) Container d) All of above

---b) Content

Q.11 Select the correct source code using swing for generating following output.

a) b)
public class AppletDemo extends public class AppletDemo extends
JApplet JApplet
{ {
public void paint(Graphics g) public void paint(Graphics g)
{ {
g.string(“WELCOME TO SWING g.drawString(“WELCOME TO
PROGRAM ”,20,40); SWING PROGRAM ”,20,40);
} }
} }
c) d)
public class AppletDemo public class AppletDemo extends
{ JApplet
public void paint(Graphics g) {
{ public void paint(Graphics g)
g.drawString(“WELCOME TO {
SWING PROGRAM ”,20,40); g.display(“WELCOME TO
} SWING PROGRAM ”,20,40);
} }
}
b)
public class AppletDemo extends JApplet
{
public void paint(Graphics g)
{
g.drawString(“WELCOME TO SWING PROGRAM ”,20,40);
}
}

Q.12 The component used to display following image are _______.

a) two circle, two arcs


b) three circle, one arc and one rectangle
c) Four circles
d) three circles and one arc

---d) three circles and one arc

Q.13 To represent Icon file in swing label we use


a) setimg b) setIcon
c) setLabelIcon d) None of these

---b) setIcon

Q.14 Which of the following component allows multiple selection?


a) JList b) JComboBox
c) JLabel d) All of the above

---a) JList
Q.15 To generate above output we need _______.

a) List, choice,Button, ImageIcon


b) ComboBox, ImageIcon, Label
c) List and Image Icon
d) ComboBox and ImageIcon

---d) ComboBox and ImageIcon

Q.16 To generate following output the components that are used are _______.

a) Checkbox, Textbox b) Radiobutton, Textbox


c) Checkbox, Button d) List, Textbox

---a) Checkbox, Textbox

Q.17 The subclass of JToggleButton is ______.


a) JButton b) JCheckBox
c) JRadioButton d) Both b and c
---d) Both b and c
Q.18 The swing component classes that are used in Encapsulates a mutually exclusive set of
buttons?
a) AbstractButton b) ButtonGroup
c) JButton d) ImageIcon
--- b) ButtonGroup
Q.19 Select the correct output generated by following code
import java.awt.*;
import java,applet.*;
/*<applet code=Test.class height=200 width=200>
</applet>*/Public class Test extends Applet
{
Public void init()
{
List l=new List(2,true);
l.add(“Java”);
l.add(“C++”);
l.add(“Python”);
add(l);
}
}

a) b)

c) d)

----c)
Q.20 Which method of the component class is used to set the position and size of a component.
a) setPosition b) setBounds
c) setSize d) None of these

---b) setBounds

Q.21 Select the correct option


I. Canvas is a component
II. ScrollPane is a container
a) I is true and II is false b) I is false and II is true
c) I and II both are false d) I and II both are true

----a) I is true and II is false

Q.22 The difference between Scrollbar and Scrollpane is


a) Scrollbar is component and Scrollpane is container
b) Scrollbar is container and Scrollpane is component
c) Scrollbar and Scrollpane both are components and not containers
d) Scrollbar and Scrollpane both are containers and not components

---a) Scrollbar is component and Scrollpane is container

Q.23 Frame class Extends Window.


a) True b) False

--- a) True
Q.24 Which is the container class?
a) Window b) Frame
c) Dialog d) All of the above

---d) All of the above

Q.25 Following is uneditable control


a) Button b) TextField
c) Label d) List

---c) Label

Q.26 Debug following program


import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
/*<applet code=”TableDemo” width=300 height=100>
</applet>*/
public class TableDemo extends JApplet
{
public void init ()
{
Container contentPane=getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] th={“Name”,”City”,”Salary”,”Designation”};
final Object[][] mytable={
{“Arun”,”Pune”,”5000”,”Accountant”},
{“Archana”,”Mumbai”,”7000”,”Executive”},
{“Shivani”,”Bangalore”,”10000”,”Manager”},
{“Priyanka”,”Chennai”,”8000”,”Programmer”},
{“Monika”,”Hyderabad”,”10000”,”Designer”},
{“Shilpa”,”Hyderabad”,”12000”,”Director”},
{“Anuja”,”Delhi”,”17000”,”Director”},
{“Kumar”,”Pune”,”10000”,”Manager”},
};
JTable table=new JTable(mytable);
int vscrollbar=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int hscrollbar= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane mypane=new JScrollPane(table,vscrollbar,hscrollbar);
contentPane.add(mypane,BorderLayout.CENTER);
}
}
a) Error in statement in which JTable is created.
b) Error in statement in which JScrollPane is created
c) Error in statement in which applet tag is declared
d) None of these

---a) Error in statement in which JTable is created.

Q.27 JPanel and Applet use _______ as their Default Layout.


a) FlowLayout b) GridLayout
c) BorderLayout d) GridBagLayout

---a) FlowLayout

Q.28 Which components are used to generate following output?

a) Panel, Tabbed Pane, Radio Button


b) Tabbed Pane, List
c) Tabbed Pane, Panel
d) Label, Tabbed Pane, Checkbox

---a) Panel, Tabbed Pane, Radio Button


Q.29 MVC stands for _______.
a) Model Version Control
b) Model View Controller
c) Mini View Controller
d) Major View Controller
---b) Model View Controller
Q.30 MVC architecture is used by Swing
a) True b) False

---b) False

Q.31 In Swing ______ gives the visual representation of the component


a) Model b) View
c) Controller d) None of these

---b) View

Q.32 In swing the event handling task is carried out by ______.


a) Model b) View
c) Controller d) None of these

---c) Controller

Q.33 ______ represents enterprise data and the business rules that gives access to enterprise data.
a) Model b) View
c) Controller d) None of these

---a) Model

Q.34 A _____ is component that represents a hierarchical view of data .


a) JTable b) JTree
c) JMenuBar d) None of these

---b) JTree

Q.35 We can use ______ pane to add component to container


a) contentpane b) rootpane
c) glasspane d) all

---a) contentpane

Q.36 In swing, the content pane can be obtained via method ______.
a) getContentPane b) addContentPane
c) both a&b d) None of these

---a) getContentPane

Q.37 In a swing ____ is a component that display rows and columns of data.
a) table b) card
c) both a&b d) None of these

--- a) table

Q.38 In a swing, tables are implemented by the ______ class.


a) JPanel b) JTable
c) JTree d) None of these

---b) JTable
Q.39 To use the swing components _____ package is imported.
a) java.awt b) java.swing
c) javax.swing d) None of these

---c) javax.swing

Q.40 _____ is base class for all swing components.


a) Object b) JComponent
c) Container d) None of these

---b) JComponent

Q.41 The ______ is a fundamental swing class.


a) JApplet b)JFrame
c) JPanel d) None of these

---b)JFrame

Q.42 The JTextField is extended from _____ class.


a) JApplet b) JComponent
c) JFrame d) All of these

---b) JComponent

Q.43 JTextField has ____number of constructors.


a) 5 b) 4
c) 3 d) 2

---c) 3

Q.44 JCheckBox is implementation of _____ class.


a) JButton b) AbstractButton
c) JCheckBox d) None of these

---b) AbstractButton

Q.45 JCheckBox has _____ number of constructors.


a) 5 b) 2
c) 4 d) 3

---c) 4

Q.46 ______ is a component which contains group of folders.


a) TabbedPane b) JTabbedPane
c) both a&b d) None of these

---b) JTabbedPane

Q.47 JTabbedPane class is extended by ______ class.


a) JComponent b) JApplet
c) JFrame d) None of these

---a) JComponent
Q.48 Which constructor is JComboBox class?
a) JComboBox() b) JcomboBox()
c) Both a&b d) JCombobox()

---a) JComboBox()

Q.49 Which method is used for add items in JComboBox?


a) add() b) addItem()
c) Both a&b d) None of these

---b) addItem()

Q.50 Which component is used for creating a GUI for downloading or transferring of file.
a) JLable b) JButton
c) JProgressBar d) JProgressbar

---c) JProgressBar

Q.51 Which panes are support to JApplet ?


a) Root Panes b) Glass Panes
c) Content Panes d) All of these

---d) All of these

Q.52 All Swing components names start with J.


a) True b) False

---b) False

Q.53 JProgressBar has _______ numbers of methods.


a) 3 b) 2
c) 4 d) 1
---a) 3
Q.54 You can create a tool tip for _________with setToolTipText() method.
a) JProgressBar b) JApplet
c) any JComponent d) None of these

---c) any JComponent

Q.55 Which class is provide a general purpose component for implementing divider lines?
a) JProgressBar b) JComponent
c) JTable d) JSeparator

---d) JSeparator

Q.56 Swing components are platform dependent.


a) False b) True

---a) False

Q.57 Features of Java Foundation Classes (JFC) is:


a) Swing GUI components b) Look and Feel support
c) Java 2D d) All of these
---d) All of these
Q.58 How many methods for ImageIcon?
a) 5 b) 1
c) 3 d) 2

---a) 5

Q.59 JTree has a 'root node' at the top most which is a parent for all nodes in the tree.
a) True b) False

---a) True

Q.60 How many constructor for JTable?


a) 2 b) 1
c) 4 d) 5

---d) 5

You might also like