MCQs On 2nd

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

Unit 2 : MCQs

Pruthviraj D.

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

Q. 2 Swing is not a part of JFC (Java Foundation Classes)


that is used to create GUI application?
(a) True
(b) False

Q. 3 The Swing Component classes that are used in


Encapsulates a mutually exclusive set of buttons?
(a) AbstractButton
(b) ButtonGroup
(c) JButton
(d) ImageIcon

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

Q. 5 Which package is used for import the swing


components?
(a) java.swing
(b) java.awt
(c) javax.swing
(d) All of the above

Q. 6. What is purpose of JTree?


(a) To show data in 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.

Q. 7 MVC architecture is _________


(a) Modelling – Visual – Controller
(b) Model – View – Controller
(c) Model – Viewable – Controller
(d) Many – View – Controller

Q. 8 Which package is used for imporing swing


components?
(a) java.swing
(b) javax.swing
(c) java.awt.
(d) All of the above

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


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

Q. 10 JTree class belongs to which package?


(a) java.awt
(b) java.applet
(c) java.swing
(d) javax.swing

Vansh B.

Q 1: What is Java Swing?


A) A dance style
B) A graphical user interface (GUI) library for Java
C) A type of coffee
D) A type of data structure
Answer: B) A graphical user interface (GUI) library for Java

Q 2: Which package is used for working with Java Swing components?


A) java.awt
B) java.util
C) javax.swing
D) java.io
Answer: C) javax.swing

Q 3: Which class is used to create a top-level window in Java Swing?


A) JFrame
B) JPanel
C) JWindow
D) JDialog
Answer: A) JFrame

Q 4: Which Swing layout manager arranges components in a grid of rows and


columns?
A) FlowLayout
B) BorderLayout
C) GridLayout
D) CardLayout
Answer: C) GridLayout

Q 5: Which Swing component is used to display a single line of editable text?


A) JTextArea
B) JTextField
C) JTextPane
D) JEditorPane
Answer: B) JTextField

Q 6: What event is fired when a button is clicked in Java Swing?


A) KeyEvent
B) MouseEvent
C) ActionEvent
D) WindowEvent
Answer: C) ActionEvent

Q 7: Which method is used to add components to a container in Java Swing?


A) addComponent()
B) insertComponent()
C) attachComponent()
D) add()
Answer: D) add()

Q 8: Which Swing component is used to display a list of items that can be


selected?
A) JComboBox
B) JList
C) JTable
D) JScrollPanel
Answer: B) JList

Q 9: Which class is used to create a menu bar in Java Swing?


A) JMenuBar
B) JMenu
C) JMenuItem
D) JPopupMenu
Answer: A) JMenuBar

Q 10: Which method is used to close a JFrame and terminate the application?
A) close()
B) dispose()
C) exit()
D) terminate()
Answer: B) dispose()

Shreyash Chudiwal:

Q.1 Which of the following is NOT a feature of Swing?


a) Platform-independent look and feel
b) Lightweight components
c) Dependency on native operating system widgets
d) Enhanced graphics capabilities
Correct answer: c

Q.2 Which Java GUI toolkit offers a more modern and flexible alternative to
AWT?
a) JavaFX
b) Swing
c) SWT
d) JavaGUI
Correct answer: b

Q.3 What is the purpose of a JButton component in Swing?


a) Display images
b) Display text
c) Provide a clickable button
d) Create a checkbox
Correct answer: c

Q.4 Which component is used to create a drop-down list of options in Swing?


a) JList
b) JComboList
c) JDropDown
d) JComboBox
Correct answer: d

Q.5 Which Swing component is used to display hierarchical data?


a) JTree
b) JTable
c) JList
d) JHierarchy
Correct answer: a

Q.6 In the context of Swing, what is the purpose of a JTabbedPane?


a) Display multiple components in a tabular layout
b) Provide a tabular representation of database records
c) Create a tabbed interface for web browsing
d) Display a list of tabs for navigation
Correct answer: a

Q.7 Which Swing component provides scroll bars for viewing content that doesn't
fit within its visible area?
a) JScrollArea
b) JViewport
c) JScrollPane
d) JScrollBar
Correct answer: c
Q.8 What does MVC stand for in the context of Swing architecture?
a) Model-View-Canvas
b) Model-Viewer-Controller
c) Multi-View-Component
d) Model-View-Controller
Correct answer: d

Q.9 Which Swing component is used to show the progress of a task?


a) JProgressBar
b) JProgressIndicator
c) JStatusIndicator
d) JTaskMonitor
Correct answer: a

Q.10 What is the key advantage of using Swing over AWT?


a) Native look and feel
b) Dependency on the operating system's widgets
c) Limited customization options
d) Lightweight component
Correct answer: d

Prashant Kalaphad:

1. Which of the following architecture does the Swing framework use?


MVC
MVP
Layered architecture
Master-Slave architecture
Answer: A) MVC

2. Which language is used in the swing framework?


JavaScript
Java
React
Python
Answer: B) Java
3. A ____ is the abstract foundation class for SWING's non-menu user interface
controls?
Container
Jcomponent
Component
Answer: C) Component

4. A ____ is the basic class for all SWING UI components?


Container
Jcomponent
Component
Answer: B) Jcomponent

5. A ____ is a one-line input field that allows the user to choose a number or an
object value from an ordered sequence?
JTextarea
Jtextfield
Jspinner
Jslider
Answer: C) Jspinner

6. A ____ control is a dialogue window that allows the user to pick a file?

JChoosFile
JFilefield
JFile
JFileChooser
Answer: D) JFileChooser

7. An ____ is a change in the state of an item?


Spinner
Event
Occurrence
Activity
Answer: B) Event

8. How many types of events are there?


5
3
2
4
Answer: C) 2

9) Which of the following type of events requires direct interaction with the user?
Foreground events
Background events
Answer: A) Foreground events

10. Which of the following type of events requires direct interaction with the end-
user?
Foreground events
Background events
Answer: B) Background events

Tanmay Gawali:

Q1.Full form of MVC?


i. Model View Controller
ii. Model View Class
iii. Model Virtual Controller
iv. Multi Viewer Class
Q2.Swing Component start with name?
i. J
ii. j
iii. a
iv. A
Q3.Default Layout of Frame in swing is?
i. BorderLayout
ii. CardLayout
iii. FlowLayout
iv. GridBagLayout
Q4.Which Program of JButton is correct?
i. import java.awt.*;
import javax.swing.*;
public class ButtonEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
ImageIcon m=new ImageIcon(“Flower.jpg”);
JButton b=new JButton(m);
b.setBounds(10,20,100,200);
f.add(b);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}

ii. import java.awt.*;


import javax.swing.*;
public class ButtonEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
JImageIcon m=new JImageIcon(“Flower.jpg”);
JButton b=new JButton(m);
b.setBound(10,20,100,200);
f.add(b);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}

iii. import java.awt.*;


import java.swing.*;
public class ButtonEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
ImageIcon m=new ImageIcon(“Flower.jpg”);
JButton b=new JButton(m);
b.setBounds(10,20,100,200);
f.add(b);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}

iv. import java.awt.*;


import javax.swing.*;
public class ButtonEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
ImageIcon m=new ImageIcon(“Flower.jpg”);
JButton b=new JButton(m);
b.setBounds(10,20,100,200);
f.add(m);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
Q5.Default layout of Applet in Swing is?
i. BorderLayout
ii. FlowLayout
iii. CardLayout
iv. GridLayout
Q6.Full Form of JFC is?
i. Java Function Classes
ii. Java Function Controller
iii. Java Foundation Classes
iv. Java Founder Class
Q7. Which Package is not import in swing?
i. import java.swing.*;
ii. import javax.swing.event.*;
iii. import javax.swing.container.*;
iv. import javax.swing.container;
Q8.Which Program of JScrollPane is incorrect?
i. import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class DemoEx extends Applet
{
public void init()
{
setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(10,10));
int b=0;
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
jp.add(new JButton(“Button ”+b));
b++;
}
}
int
vsb=ScrollPaneContants.VERTICAL_SCROLLBAR_AS_NEEDED;
int
hsb=ScrollPaneContants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane.jp=JScrollPane(jp,vsb,hsb);
add(jp,BorderLayout.CENTER);
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

ii. import java.applet.*;


import java.awt.*;
import javax.swing.*;
public class DemoEx extends Applet
{
public void init()
{
setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(10,10));
int b=0;
for(int i=1;i<10;i++)
{
for(int j=0;j<10;j++)
{
jp.add(new JButton(“Button ”+b));
b++;
}
}
int
vsb=ScrollPaneContants.VERTICAL_SCROLLBAR_AS_NEEDED;
int
hsb=ScrollPaneContants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane.jp=JscrollPane(jp,vsb,hsb);
add(jp,BorderLayout.CENTER);
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

iii. import java.applet.*;


import java.awt.*;
import javax.swing.*;
public class DemoEx extends Applet
{
public void init()
{
setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(10,10));
int b=0;
for(int i=1;i<10;i++)
{
for(int j=0;j<10;j++)
{
jp.add(new JButton(“Button ”+b));
b++;
}
}
int
vsb=ScrollPaneContants.VERTICAL_SCROLLBAR_AS_NEEDED;
int
hsb=ScrollPaneContants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane.jp=JScrollPane(jp,vsb,hsb);
add(jp,BorderLayout.CENTER);
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

iv. import java.applet.*;


import java.awt.*;
import javax.swing.*;
public class DemoEx extends Applet
{
public void init()
{
setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(10,10));
int b=0;
for(int i=1;i<10;i++)
{
for(int j=0;j<10;j++)
{
jp.add(new JButton(“Button ”+b));
b++;
}
}
int
vsb=ScrollPaneContants.VERTICAL_SCROLLBAR_AS_NEEDED;
int
hsb=ScrollPaneContants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane.jp=JScrollPane(jp,vsb,hsb);
add(jp,BorderLayout.CENTER);
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

Q9.Which Program of JTable is Correct?


i. import javax.swing.*;
import java.awt.*;
public class DemoEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
String data[][]={{“101”,”Shriraj”,”300000”},
{“102”,”Atharv”,”300000”},{“103”,”Tanmay”,”300000”}};
String column[]={“Id”,”Name”,”Salary”};
JTable jt=new JTable(data,columns);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
ii. import javax.swing.*;
import java.awt.*;
public class DemoEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
String data[][]={{“101”,”Shriraj”,”300000”},
{“102”,”Atharv”,”300000”},{“103”,”Tanmay”,”300000”}};
String column[]={“Id”,”Name”,”Salary”};
JTable jt=new JTable(datas,column);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
iii. import javax.swing.*;
import java.awt.*;
public class DemoEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
String data[][]={{“101”,”Shriraj”,”300000”},
{“102”,”Atharv”,”300000”},{“103”,”Tanmay”,”300000”}};
String column[]={“Id”,”Name”,”Salary”};
JTable jt=new JTable(data,column);
jt.setBound(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
iv. import javax.swing.*;
import java.awt.*;
public class DemoEx
{
public static void main(String[] args)
{
JFrame f=new JFrame();
String data[][]={{“101”,”Shriraj”,”300000”},
{“102”,”Atharv”,”300000”},{“103”,”Tanmay”,”300000”}};
String column[]={“Id”,”Name”,”Salary”};
JTable jt=new JTable(data,column);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
Q10. Which Program of ImageIcon is incorrect?
i. import java.awt.*;
import java.swing.*;
import java.applet.*;
public class DemoEx extends Applet
{
public void init()
{
Container cp=getContentsPane();
ImageIcon im=new ImageIcon(“Flower.jpg”);
JLabel l1=new JLabel(im.CENTER);
cp(l1)
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

ii. import java.awt.*;


import javax.swing.*;
import java.applet.*;
public class DemoEx extends Applet
{
public void init()
{
Container cp=getContentPane();
ImageIcon im=new ImageIcon(“Flower.jpg”);
JLabel l1=new JLabel(im.CENTER);
cp(l1)
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/
iii. import java.awt.*;
import javax.swing.*;
import java.applet.*;
public class DemoEx extends Applet
{
public void init()
{
Container cp=getContentPane();
ImageIcon im=new ImageIcon(“Flower.jpg”);
JLabel l1=new JLabel(im.CENTER);
cp(l1)
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/
iv. import java.awt.*;
import javax.swing.*;
import java.applet.*;
public class DemoEx extends Applet
{
public void init()
{
Container cp=getContentPane();
ImageIcon im=new ImageIcon(“Flower.jpg”);
JLabel l1=new JLabel(im.CENTER);
cp(l1)
}
}
/*<applet code=”DemoEx.class” width=300 height=300> </applet>*/

Nishikant Madhukar Yeole

1. What does GUI stand for?


a) Graphical User Interface
b) General User Interface
c) Graphics Utility Interface
d) Graphical Utility Interface

2. Which package contains the Java Swing classes?


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

3. Which class is used as the base class for all Swing components?
a) Component
b) Container
c) JPanel
d) JFrame
4. Which layout manager is used by default for JFrame?
a) BorderLayout
b) FlowLayout
c) GridLayout
d) CardLayout

5. Which class is used to create a button in Java Swing?


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

6. Which event listener interface is used for handling button click events?
a) ActionListener
b) ItemListener
c) MouseListener
d) KeyListener

7. What is the purpose of the setVisible() method in JFrame?


a) To set the size of the frame
b) To set the title of the frame
c) To make the frame visible on the screen
d) To close the frame

8. Which method is used to add components to a container in Java Swing?


a) add()
b) setComponent()
c) insert()
d) append()

9. What is the purpose of the setLayout() method in Java Swing?


a) To set the background color of a component
b) To set the size of a component
c) To set the layout manager for a container
d) To set the font style for a component

10. Which layout manager is used to arrange components in a grid-like


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

Atharva G.

What is Swing in Java?


A. A programming language
B. A type of dance
C. A graphical user interface (GUI) toolkit
D. A data structure

Ans:C

Which class is the base class for all Swing components?


A. java.awt.Component
B. java.awt.Container
C. javax.swing.JComponent
D. javax.swing.JPanel

Answer: C. javax.swing.JComponent

Which of the following is not a Swing container?


A. JFrame
B. JDialog
C. JButton
D. JTabbedPane

Answer: C. JButton is not a container

Which of the following is not a Swing component?


A. JTextArea
B. JLabel
C. JScrollPane
D. JPanelAnswer: C
Which of the following components can display images?
A. JTextArea
B. JTable
C. JList
D. JLabel

Answer: D

Which of the following components can be used to select a color?


A. JSlider
B. JColorChooser
C. JSpinner
D. JCheckBox

Answer: B

Which of the following methods is used to add a component to a container?


A. addComponent()
B. addContainer()
C. addComponentToContainer()
D. add()

Answer: D

Which of the following methods is used to set the title of a JFrame?


A. setTitle()
B. setLabel()
C. setText()
D. setCaption()

Answer: A

Which of the following methods is used to add an ActionListener to a JButton


object?
A. addAction()
B. addActionListener()
C. addListener()
D. addEventHandler()

Answer: B
Which of the following methods is used to display a JOptionPane dialog box?
A. showMessageDialog()
B. showInputDialog()
C. showOptionDialog()
D. showConfirmDialog()

Answer: A

Jay Bankar:

1) Package of drawstring() method is


A. java.applet
B. java.io
C. javax.swing
D. java.awt
Option D

2)Which method is used for getting the language in internationalization?


A. getDisplayLanguage()
B. GetdisplayLanguage()
C. GetDisplayLanguage()
D. none
Option A

3)What are types of applets?


A. Trusted Applets
B. Untrusted applets
C. Both A and B
D. None of these
Option C

4)Give the abbreviation of AWT?


A. Applet Windowing Toolkit
B. Abstract Windowing Toolkit
C. Absolute Windowing Toolkit
D. None of the above
Option B

5)Which of these methods can be used to know which key is pressed?


A. getActionEvent()
B. getActionKey()
C. getModifier()
D. getKey()
Option C
6)Object which can store group of other objects is called
A. Collection object
B. Java object
C. Package
D. Wrapper
Option A

7)All collection classes are available in


A. java.io package
B. java.lang package
C. java.awt package
D. java.util package
Option D

8)In Java, what do you call an area on the screen that has nice borders and various
buttons along the top border?
A. A window
B. A screen
C. A box
D. A frame
Option D

9)What is the Lifecycle of an applet?


A. init( ) method
B. start( ) method
C. paint( ) method
D. All of these
Option D

10)What are the names of the list layout managers in Java?


A. Flow Layout Manager
B. Grid Layout Manager
C. Box Layout Manager
D. All of the above
Option D
Uday Theta:

1.Which is used for import the swing components.


a)java⋅ Swing
by java.awt
c) javax.swing
d) all of the above

2.In Swing, Buttons are subclasses of which class?


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

3.which component in swing represents data in rows and columns.


a)JTextArea
b)JTabbedPane
c)JTable
d)JButton

4......class is used to create node in tree.


a)TreeNode
b)DefaultNode
c)DefaultMutableTreeNode
d) node.

5.which of the following method is not applicable for Button in Swing.


a)setDiableIcon
6) setPressedIcon
c) setSelectedIcon
d)setRollOverIcon
6.From following list which is not swing class?
a)J Label
b)JButton
c)JImageIcon
d)JcheckBox
7.which method is used to define the tabs in tabbed pane?
a)add()
b)addItem ()
c)addPane()
d)addTab()
8.The tree node is a ..
a)class
b)an interface.
c)a variable.
d)nothing.
9.MVC architechture is-
a) Modelling - visual - Controller
b) Model-view-Controller c) Model-viewable- Controller
d)Many-view-Controller.
10.what is purpose of Tree?
a)To show data in form of parent & child node.
b)to show data in list view.
c)To show data in tabular form.
d)To show data in menu-bar.

Ans--
1)c
2)a
3)b
4)c
5)c
6)c
7)d
8)c
9)b
10)a

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy