0% found this document useful (0 votes)
262 views16 pages

Ajp Question MCQ

The document contains questions about AWT and Swing components and concepts. It asks about commonly used methods, ways to create frames, abbreviations, components that can display choices or text, layout managers, controls supported, applet lifecycles, running applets, text area constructors, panel class hierarchy, default frame layout, missing menu item addition, components for output examples, platform dependence, JTree constructors, invalid JLabel methods, adding components to containers, default applet layout, non-Swing classes, text area constructors, JTable class, making text fields read only, flow layout arrangement, label parameter purpose, panel class hierarchy, default frame layout, applet superclass, event superclass, retrieving button

Uploaded by

Rutuja Pote
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)
262 views16 pages

Ajp Question MCQ

The document contains questions about AWT and Swing components and concepts. It asks about commonly used methods, ways to create frames, abbreviations, components that can display choices or text, layout managers, controls supported, applet lifecycles, running applets, text area constructors, panel class hierarchy, default frame layout, missing menu item addition, components for output examples, platform dependence, JTree constructors, invalid JLabel methods, adding components to containers, default applet layout, non-Swing classes, text area constructors, JTable class, making text fields read only, flow layout arrangement, label parameter purpose, panel class hierarchy, default frame layout, applet superclass, event superclass, retrieving button

Uploaded by

Rutuja Pote
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/ 16

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

3) Give the abbreviation of AWT?


a. Applet Windowing Toolkit b. Abstract Windowing Toolkit

c. Absolute Windowing Toolkit d. None of the above

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

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


a. setText() b. getText()

c. All the aboved. None of the above

6) Which is a component in AWT that can contain another components like buttons, textfields,
labels etc.?
a. Window b. Container

c. Panel d. Frame

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

8) How many types of controls does AWT support?


a. 7 b. 6 c. 5 d. 8
9) Which life cycle method of an applet java.awt.Component class provides?

A) public void paint(Graphics g)


B) public void destroy()
C) public void stop()
D) public void init()

10 )Which is the correct order for lifecycle of an applet?

A) Applet is intialized,started,painted,destroyed,stopped
B) Applet is painted,started,stopped,initilaized,destroyed
C) Applet is initialized,started,painted,stopped,destroyed
D) None of the above

11) To run an Applet which of these used?

A) By html file
B) By AppletViewer tool(for testing purpose)
C) Both A & B
D) None of the above

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

A) True B) False

13) If we want to create TextArea of 100 character in width and 30 character in height, which is
correct constructor for achieve our scenario?

a) new TextArea(100,30)
b) new TextArea(30,100)
c) new TextArea(100,30,100,30)
d) All of these

14) What is correct hierarchy of Panel class?

a) Component->Container->Panel
b) Component->Container->Window->Frame->Panel
c) Component->Container->Window->Panel
d) Container->Component->Panel

15) What is default layout for Frame?

a. BorderLayout b. FlowLayouc.
C.FrameDefaultLayout d. GridLayout
16) Select the missing statement in
the program for following output
import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1); } }

A.mbr.add(view); B.mbr.add(menu);

C.mbr.add(vieweditmenu); D.mbr.add(viewmenu);

17 .Which Component are used in following output?

a.Label,TextField,Button b.Applet ,label

c.Applet,Button d.GridLayout,label,Button
18..Which component will be needed to get following output?

a.Label,Tabbedpane,Checkbox, b.Tabbedpane,List,Applet,

c.Panel,TabbedPane,List d.Applet,TabbedPane,Panel

19.Swing Components are_______________________


a. Platform dependent
b. Platform Independent
c. Both a & b
d. Platform oriented

20. Which of the following is not a constructor of JTree


A. JTree(Object obj[]) B. JTree(TreeNodetn)
C. JTree(Vector v) D. JTree(int x)

21. Which of these methods cannot be called on JLabel object?


A. setIcon()
B. getText()
C. setLabel()
D. setBorderLayout()

22. _____________ pane can be used to add component to container


A. Glass B. Cotent C. Container D. All of above

23.Which of the following is true about AWT and Swing Component?


A. AWT Components create a process where as Swing Component create a thread
B. AWT Components create a thread where as Swing Component create a process
C. Both AWT and Swing Component create a process
D. Both AWT and Swing Component create a thread

24. JPanel and Applet use ___________________ as their default layout


A. FlowLayout B. GridLayout
C. BorderLayout D. GridBagLayout
25.Which class can be used to represent the Checkbox with a textual label that can appear in a
menu?
A. MenuBar B. MenuItem
C. CheckboxMenuItem D. Menu

26..To get the following output complete the code give n below:

27. Which method is used to set layout of Applet?

a. setBorderLayout() c. setLayout()
b. setLayoutManager() d.setAppletLayout()

28. We can set alignment of string in Label control by using ___________method?

a) setText() b.setString()b setAlignment() d.setStringAlignment()


29.Which controls are platform dependent?

a) AWT c.Swing
b) MVC d.All of the above

30. What is default layout Manager for JApplet?

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

31. Which is not swing class from following?

1. JApplet
2. JFrame
3. JLabel
4. Canvas

32 If we want to create TextArea of 100 character in width and 30 character in height, which is
correct constructor for achieve our scenario?

1. new TextArea(100,30)
2. new TextArea(30,100)
3. new TextArea(100,30,100,30)
4. All of these

33. Which class is used to create table in swing?

1. JTable
2. Table
3. JTableSwing
4. JTableRoot

34.I want to make my TextField is read only state, which TextComponent method is used?

1. Editable
2. setEditable()
3. setNonEditable()
4. setEchoChar()

35. Flow Layout is arranges components in _________________ way.

1. Left to Right
2. Right to Left
3. North to East
4. East to West

36.Consider Label(String, int), what is purpose of second parameter?

1. It specifies height of parameter


2. It specifies width of Label
3. It specifies alignment of text in Label
4. None of the Above

37.What is correct hierarchy of Panel class?

1. Component->Container->Panel
2. Component->Container->Window->Frame->Panel
3. Component->Container->Window->Panel
4. Container->Component->Panel

38.What is default layout for Frame?

b. BorderLayout
c. FlowLayout
d. FrameDefaultLayout
e. GridLayout

39. Which is immediate super class of Applet

1. JApplet
2. JPanel
3. Panel
4. Container

40. _______ is superclass of all the events in AWT package.

1. EventObject
2. Event
3. AWTEvent
4. SuperAWTEvent

41. EventObject class is present in ________ package.

1. java.swing
2. java.awt.event
3. java.util
4. java.awt

42 _________ method is used for retrieving label of Button.


1. getActionCommand()
2. getLabel()
3. getString()
4. getAction()

43.Which method is used to end the life cycle of Servlet?

1. setVisible(false)
2. stop()
3. destroy()
4. dispose()

44 ButtonGroup g = new ButtonGroup(): This statement is used to create _______.

1. RadioButton
2. CheckBox
3. CheckBoxGroup
4. ComboBoxGroup

45. Which method is used to get the current value of scroll-bar?

1. getCurrentValue()
2. getCurrentValueScrollbar()
3. getValue()
4. getSelect()

46._______ pane can be used to add components to the container.

1. Glass
2. Component
3. Content
4. Container

47.Which is Cosmic (base) superclass of Java? or All the classes in java is derived from ______.

1. Object
2. Class
3. EventObject
4. AWTEvent

48. JCheckBoxMenuItem is subclass of __________ class.

a) JComponent c. JMenuItem
b) JButton d. None of these
49.What is the purpose of JTable ?

a. JTable object display rows of data.

b. JTable object display columns of data.

c. JTable object display rows and columns of data.

d. JTable object display data in Tree from.

50.Which method is used to display icon on a component?

a.rollOverIcon(ImageIcon i)

b.setIcon(ImageIcon i)

c.displayIcon(ImageIcon i)

d.removeIcon(ImageIcon i)

51. Which components are needed to get above


shown output

A. TextField, Label
B. List, Button
C. Choice, Button
D. Button, TextField

52. select the proper output for following code2M

import java.awt.*; import java.applet.*;

public class list2 extends Applet{


public void init(){

List l= new List(2,true); l.add("java"); l.add("c++"); l.add("kkk");

add(l);}

}/*<applet code=list2.class height=200 width=200> </applet>*/

a.

c.

c.

d.
Debug the following program2M

53.import java.awt.*; import javax.swing.*; /*

<applet code="JTableDemo" width=400 height=200> </applet>

*/

public class JTableDemo extends JApplet

public void init() {

Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout());

final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" }; final Object[][] data = {

{"Ramesh", "111", "50000" },

{"Sagar", "222", "52000" },

{"Virag", "333", "40000" },

{"Amit", "444", "62000" },

{"Anil", "555", "60000" },

67

};

JTable table = new JTable(data);

int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =


ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new
JScrollPane(table, v, h);

contentPane.add(jsp, 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 the above

31. Which layout arranges (lays) the components in two dimensional?

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

 Which method can be used to get degree of adjustment made by the user?

a) getAdjustment()
b) getValue()
c) getAdjustmentValue()
d) None of these

 Which is super class for FocusEvent, WindowEvent and ContainerEvent is

a) ComponentEvent
b) ActionEvent
c) InputEvent
d) All of the above

 Which is correct Adapter class from following?

1. ItemAdapter
2. ButtonAdapter
3. ActionAdapter
4. MouseAdapter

 Which is correct method for registering mouse listener?

1. addMouseListener()
2. registerMouseLIstener()
3. addMouseMotionListener()
4. registerMouseMotionListener()


 How to get name of control which generate ActionEvent?

1. getName()
2. getActionCommand()
3. getActionNameControl()
4. obtainAction()

 Which object is notified and respond to the event?

1. Event Source
2. Action Object
3. Event
4. Notified Object

 _______ is superclass of All the events in Java.

1. EventObject
2. Event
3. AWTEvent
4. SuperJavaEvent

 MouseEvent is subclass of _______ class. (Or Which is superclass of MouseEvent)

1. MouseEventObject
2. TextEvent
3. InputEvent
4. EventObject

 Select correct option for List Control events:

1. ActionEvent, TextEvent
2. ItemEvent, KeyEvent
3. ActionEvent, ItemEvent
4. FocusEvent, ActionEvent

 _______ event is generated when user interacts with scrollbars.

1. ScollbarEvent
2. AdjustmentEvent
3. ActionEvent
4. MouseEvent

 AWT components create __________ and swing components create ________.


1. Thread, Process
2. Process, Thread
3. Process, Process
4. Thread, Thread

 ActionListener interface extends _______ interface.

1. TextListener
2. EventListener
3. EventObject
4. ActionListenerBase

 MouseListener interface has _______ number of methods.

1. 7
2. 8
3. 9
4. 10

 What is default port number for TCP?

1. 80
2. 81
3. 82
4. 90

 Consider the provided link, understand it and choose correct option: Param1 and Param2 are
the names of parameter

1. Get method is used for passing parameters


2. Part after ‘?’ is called Query String
3. All of the above.

 Which file defines the servlet mapping?

1. ServletMapping.xml
2. Servlet.xml
3. ServletConfig.xml
4. web.xml

 Which is correct option for get method?

1. We can not send data using get method because post method is used to send data.
2. With the help of body part
3. With the help of payload information
4. With the help of URL

 MIME stands for ______________(Not providing options: Multipurpose Internet Mail
Extension)
 ResultSetMetaData interface object created by which method of which interface?

1. getMetaData(), ResultSet interface


2. getResultSet(), ResultSet interface
3. getMetaData(), Statment interface
4. getMetaData(), PreparedStatement Interface

 Which are methods provided by the Statement interface?

1. executeQuery()
2. executeUpdate()
3. getStatment()
4. Both 1 & 2

 Which JDBC type driver either used in Servlet or Applet?

1. Type 1
2. Type 2
3. Type 3
4. Type 4

 openConnection() method of URL class returns is

1. URLCOnnection Object
2. URL Object
3. PreparedStatment object
4. Connection object

 InetAddress class throws ______ exception (UnknowHostException).


 URL class throws ____ exception (MalFormedException)
 Which is intermediate between Server and Client. (Proxy)
 Related to MouseMotionListener, choose correct option

1. Use addMouseMotionListener method for register the listener


2. It is presnt in java.awt.event package
3. It has mouseMoved and mouseDragged methods
4. All of these are correct


 For Select SQL query which method is used in Java?

1. executeQuery()
2. executeUpdate()
3. executeSelect()
4. executeBatch()

You might also like