AJP Question Bank Class Test 1 Jan 2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

K. K. Wagh Polytechnic, Nashik.

HirabaiHaridasVidyanagari, Amrutdham,
Panchavati,Nashik-422003
Department of Computer Technology(Both Shift)
Class: TYCM-I & II Date: 23/01/2017
Question Bank
Subject: AJP (17625)

1. AWT Stands for what?


a) Advanced Web Technology b) Abstraction ToolKit
c) Abstract Window ToolKit d) Abstract Windowing ToolKit
2. Which of the following is constructor for Frame class?
a) Frame() b) Frame(String s, int how) c) Frame(int l , int b) d) Frame(int l, int b, String s)
3. Dimension class sets which of the following values?
a) length and breadth b) length and width c) length and height d) width and height
4. add() method is defined by which class?
a) Component b) Container c) Applet d) Frame
5. Which event is handled on Button component?
a) AdjustmentEvent b) FocusEvent c)KeyEvent d)ActionEvent
6. Which of the following is a passive component?
a) Label b) Button c) Checkbox d) Scrollbar
7. Label(String s, int how) does what?
a) Sets the string and alignment of Label b) Sets the string and alignment of caption of a Label
c) Sets the string and integer value 10 d) Sets the string and integer value 0
8. What is the default alignment value for Label?
a) Label.RIGHT(2) b) Label.CENTER(1) c) Label.LEFT(0) d) None
9. What is the default visibility of a Frame Window?
a) True b) False c) No such restriction d) None
10. Which method is used for setting caption of a Button?
a) setText(String s) b) setText(String s, int how) c) setLabel(String s) d) setLabel(String s, int how)
11. Which of the following constructor creates a TextField with 5 columns width?
a) TextField() b) TextField(5) c) TextField(5,5) d) Both a and b
12. How to give editing facility to TextField?
a) setEditable(true) b) setEditable (false) c) setEnable (true) d) setEnable (false)
13. How to give password field effect to the TextField?
a) setChar(char c) b) setEchoChar(char c) c) setEcho(char c) d) setCharacter(char c)
14. How to create TextArea with 2 rows and 3 columns?
a) TextArea(3,2) b) TextArea(2,3) c) TextArea(2) d) TextArea(3)
15. How to replace a Text from TextArea?
a) replace() b) replaceText() c)replaceRange() d)replaceAll()
16. How to create a List with 3 visible number of rows?
a) List() b) List(3) c) List(3,true) d) List(3,3)
17. Which constructor is used to give multiple mode selection facility to List?
a) List() b) List(3) c) List(3,true) d) List(3,false)
18. Which method is used to add elements in Choice?
a) add() b) addItem() c) add(String s,2) d) Both a and c
19. Which of the following constructor creates a Scrollbar with Vertical Orientation ?
a) Scrollbar(4) b) Scrollbar(1) c) Scrollbar() d) Scrollbar(0)
20. Which of the following component handles multiple events?
a) List b) Choice c) Scrollbar d) TextArea
21. The setLayout() method is defined by which class?
a) Applet b) Container c) Component d) Frame
22. Flow Layout is the default layout manager for which window?
a) Applet b) Container c) Component d) Frame
23. What is default alignment for Flow Layout?
a) LEFT b) CENTER c) RIGHT d) LEADING
24. What is default hgap and vgap distance for Flow Layout?
a) 10 b) 15 c)20 d)5
25. BorderLayout is the default layout manager for which window?
a) Frame b) Dialog c) Applet d) Both a and b
26. Which Layout manager requires to create Panel object?
a) Flow b) Border c) Grid d) Card
27. What is the default row and column number for Grid Layout?
a) (1,1) b) (1,2) c)(2,2) d) (0,0)
28. setBounds() method is related with which Layout manager?
a) Flow b) Border c) null d) Card
29. What is the default type of Dialog Box?
a) Modal b)Nonmodal c) No such Restriction d) None of the above
30. How to add Button object b1 to SOUTH region of BorderLayout?
a) add(b1) b)add(b1.SOUTH) c) add(b1,BorderLayout.SOUTH) d) add(b1,SOUTH)
31. What J Specifies in Swing?
a) Java b)JFC c) javac d)javah
32. Which of the following images cannot be added using ImageIcon class?
a) .jpg b) .png c) .gif d) .bmp
33. What is the default alignment for a JProgressBar?
a) LEFT b) RIGHT c) HORIZONTAL d) VERTICAL
34. What is the default placement for a JTabbedPane?
a) TOP b) BOTTOM c) CENTER d) LEADING
35. Which of the following constructors of JTree creates a root node?
a) JTree(Hashtable ht) b) JTree(Object o) c) JTree(Vector v) d) JTree(TreeNode tn)
36. Which event is handled by a JRadioButton?
a) Action b)Item c)Adjustment d) both a and b
37. Which of the following components required to be added in a JScrollPane?
a) JTabbedPane b) JTree c) JTable d) Both b and c
38. Which is the valid argument for addTab() method defined by JTabbedPane?
a) JApplet b) JFrame c) JPanel d) JDialog
39. Which of the following operation closes Frame window?
a) setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE)
b) setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
c) setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
d) setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)
40. How to set a Tool Tip Text for JLabel?
a) setToolTip(String s) b) SetToolTipText(String s) c)setTooltipText(String s) d) ToolTipText(String s)
41. Swing components that don't rely on native GUI are referred to as ___________.
a) lightweight Components b) heavyweight Components c) GUI Components d) non-GUI Components
42. __________ are referred to as heavyweight components.
a) AWT Components b) Swing Components c) GUI Components d) non-GUI Components
43. Which of the following classes is a heavyweight component?
a) JButton b) JTextField c) JFrame d) JLabel
44. Which component cannot be added to a container?
a) JPanel b) JButton c) JFrame d) JComponent
45. Which statement is false?
a) An event is an object that describes a state change in a source. b) An event can be generated as a
consequence of a person interacting with the elements in a graphical user interface. c) An event can be
disabled by Java Runtime Environment. d) Entering a character via the keyboard generates an event.
46. What layout manager should you use so that every component occupies the same size in the container?
a) a FlowLayout b) a GridLayout c) a BorderLayout d) any layout
47. Suppose a JFrame uses the GridLayout(2, 2). If you add six buttons to the frame, how many columns are
displayed?
a) 1 b) 2 c) 3 d) 4
48. Suppose a JFrame uses the GridLayout(0, 2). If you add six buttons to the frame, how many columns are
displayed?
a) 1 b) 2 c) 3 d) 4
49. To set a FlowLayout in panel jp, you can use the method __________.
a) jp.setLayout( FlowLayout()); b) jp.setLayout(new FlowLayout(FlowLayout.CENTER));
c) jp.setLayout(new FlowLayout(FlowLayout.center)); d) jp.setLayout(FlowLayout());

50. To add a component c to a JPanel p, use _________.


a) p.add(c) b) p.getContentPane(c) c) p.insert(c) d) p.append(c)

51. Which constructor creates a checkable menu item with initially checked?
1. CheckBoxMenuItem() b)CheckBoxMenuItem(String str) c)CheckBoxMenuItem(String str, true)
d)CheckBoxMenuItem(String str, false)

52. What a Label component display?


a)Text(non-editable ) b)Text (editable) c) Both a and b d)None

53. What is use of “V” in MVC Architecture?


a) View of swing b)View of GUI c)View of data d)View of Container
54. Which of the following is not event source?
a) MenuItem b) CheckboxGroup c) List d)Label
55. How to obtain the command name for invoking ActionEvent?
a) getActionCommand( ) b) getCommand( ) c) getAction( ) d) obtainAction( )
56. Which of the following component handles both Action and Item Event?
a)Button b) Checkbox c) CheckboxGroup d) List
57. ItemListener event defines this method?
a)itemEventChanged( ) b)itemEventOccured() c)itemValueChanged() d)itemStateChanged()
58. Which of the following creates a List with 3 visible items and multiple mode selection disabled?
a) new List(3,false) b) new List(3,true) c)new List(false,3) d) new List(true,3)
59. Which of the following constructor creates a Checkbox?
a) Checkbox b) Checkbox(int i) c) Checkbox(String s, int i) d)Checkbox(String s, boolean s, null)
60. Which of the following method adds item "I” to the List with deprecation warnings at the end of List?
a) addItem(“I”) b)addItem(“I”,0) c)add(“I”) d)add(“I”,0)
61. Which method is used to display icon on a JButton component?
a) rollOverIcon(ImageIcon i) b)setIcon(ImageIcon i) c) displayIcon(ImageIcon i)
d)removeIcon (ImageIcon i )
62. Which of the following handles event in Event Delegation Model?
a)Source b) Listener c) 8. Both a and b d)None of the above
63. Predict the output
class L extends JApplet { public void init()
{ ImageIcon i1 = new ImageIcon(“B1.jpg”);
JButton b1=new JButton(i1); add(b1); } }
a)Button is created with B1 image b) Button is created without image c) Blank output d)Error

64. What size of Grid is created?


public class A1 extends Applet
{ public void init()
{ setLayout(new GridLayout()); } }
a) (1,1) b) (0,0) c)(2,2) d)(3,3)
65. class Fr
{ public static void main(String ar[])
{ JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}}
a)closes frame b)disposes frame c)exit frame d)do nothing
66. Predict the output
public class A1 extends Applet { public void init()
{ setLayout(new FlowLayout());
Label l1 = new Label(“1”);
add(l1); } }
a) Blank output b) Label is added at Left c) Label is added at Right d)Label is added at Center

67. Predict the output


public class R1 extends Applet implements ItemListener {
public void init() {
Checkbox c1 = new Checkbox();
add(c1);
Label l1 = new Label();
add(l1); }
public void itemStateChanged(ItemEvent ie)
{ if(ae.getItemSelectable()==c1) l1.setText("Hi"); } }
a) Hi is printed b)No message is printed c)Blank Output d) Error
68. Select the missing statement
public class A1 extends Applet { Button b1;
Label l1;
public void init()
{ setLayout(new FlowLayout()); b1=new
Button(""Click"");
l1=new Label(); add(l1);
add(b1); }
public void actionPerformed(ActionEvent ae) {
if(ae.getSource()==b1)
l1.setText(""Hello""); } }
a) b1.addActionListener(this) b)this.addActionListener(b1) c)No statement is missing
d) b1.addActionListener()
69. Which is the immediate super class of Applet?
a) Container b) Component c) Frame d) Panel
70. The setSize( ) method is defined by this class…
a) Applet b)Component c)Frame d)Panel

71. Which class encapsulates a blank window upon which we can draw?
a) Applet b)Canvas c)Window d)Frame

72. If we want to hide the Dialog box, we can use this method…
a) setVisible( ) b)show( ) c) setHidden( ) d)hide( )

73. All the AWT controls are subclasses of which class?


a) Component b) Container c) AWTControl d)Window

74. Which alignment is not supported by Label?


a) Label.RIGHT b) Label.LEFT c) Label.CENTER d) Label.BASELINE

75. How can we create Radio buttons in AWT?


a) Using ButtonGroup class b)Using CheckboxGroup class c) Using RadioButton class
d) Using Button class

76. Multiple selections are allowed in…


a) Menu b) CheckboxGroup c) List d)Choice

77. What is default block-increment of Scrollbar?


a) 10 b)5 c) 1 d)We cannot use block increment in scrollbars.

78. Is it possible to change display character of TextField? How?


a) Not possible. b) Yes, by using setChar( ) method. c)Yes, by using setEchoChar( ) method.
d) Yes, by using setDisplayChar( ) method.

79. Which method is used to append the text at the end of TextArea?
a) append( ) b) add( ) c) appendAt( ) d)addAt( )

80. FlowLayout does not support this value of alignment…


a) FlowLayout.LEFT b)FlowLayout.CENTER c) FlowLayout.RIGHT
d) FlowLayout.BASELINE

81. BorderLayout does not support this value of alignment…


a) BorderLayout.WEST b) BorderLayout.EAST c)BorderLayout.NORTH
d) BorderLayout.MIDDLE
82. The correct constructor of Insets( ) which uses the values is…
a) Insets(int top, int left, int bottom, int right) b) Insets(int bottom, int right, int top, int left)
c) Insets(int right, int top, int left, int bottom) d)Insets(Dimesnion d1, Dimension d2)

83. How to remove the event listener?


a) Using removeListener() method. b)Using removeTypeListener() method. c) Using removeEvent( )
method. d)It is not possible to remove the event listener.

84. At the root of Java event hierarchy, which class is located?


a) AWTEvent b) Event c) EventObject d)Events

85. Action event is generated when…


a) Label is dragged b) Button is pressed c) Mouse is dragged d)Window is opened
86. What value will be taken by getActionCommand() method if no Action command
is set for a Button?
a) Caption of a Button b) object name of a Button c) null value d) Garbage Value

87. When slider of scrollbar was dragged, which event is generated?


a) Action b) Item c) Adjustment d) MouseMotion

88. Which of the following is a event source for Action Event?


a) MenuItem b) CheckboxGroup c) Window d)Label

89. AdjustmentListener event defines this method…


a) AdjustmentEventChanged( ) b) AdjustmentEventOcurred() c)AdjustmentValueChanged()
d) AdjustmentStateChanged( )

90. In which package Swing components are defined?


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

91. The super class of all swing buttons is –


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

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


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

93. Alignment constants of JLabel are the part of –


a) SwingConstants interface b)SwingConstants class c)Swing class d)Graphics class

94. How will you set icon for the Jlabel?


a)Using Icon class directly b) Using setIcon( ) method c) Using makeIcon( ) method
d) It is not possible to set icon for JLabel

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


a) void b)String c) Character array d) There is no such method

96. How will you assign the string and icon both to the JButton?
a) It is not possible b) Use the setTextIcon( ) method c)Use the setIconText( ) method
d) Intialize them directly in the constructor

97. Which event is generated when a JToggleButton is pushed?


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

98. Immediate super class of JCheckBox is –


a)AbstractButton b) JApplet c) JCkeckBoxGroup d) JToggleButton

99. The constructor JCheckBox(true, “YES”) suggests that –


a) Checkbox is selected 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.

100. When JCheckBox is clicked the _____ event is generated.


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

101. How can we create Radio buttons?


a) Using ButtonGroup class b) Using JCheckboxGroup class c) Using JRadioButton class
d)Using JButton class
102. How to make the group of Radio buttons?
a)Using ButtonGroup class b) Using JButtonGroup class c) Using JRadioButton
d) Using AbstractButton class

103. How to add 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( )

104. How to prevent the drop-down list of JComboBox?


a) It is not possible b) We can use method preventDropMenu( ) method c) Directly give the value false
in the constructor d)Use setList( ) method.

105. Analyze the following code.

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

public class Test {


public static void main(String[] args) {
JButton c = new JButton("OK");
JFrame frame = new JFrame("My Frame");
frame.add(c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} }

a) b) c) d) Error

106. Analyze the following code.

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

public class Test {


public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
frame.add(new JButton("OK"));
frame.add(new JButton("Cancel"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
a) Only button OK is displayed b) Only button Cancel is displayed
c) Both button OK and button Cancel are displayed and button OK is displayed on the left side of
button OK d) Both button OK and button Cancel are displayed and button OK is displayed on the
right side of button OK

107. How many frames are displayed?

import javax.swing.*;

public class Test {


public static void main(String[] args) {
JFrame f1 = new JFrame("My Frame");
JFrame f2 = f1;
JFrame f3 = f2;
f1.setVisible(true);
f2.setVisible(true);
f3.setVisible(true);
}
}

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

108. Which of the following statements is for placing the frame's upper left corner to (200, 100)?
a) frame.setLocation(100, 100) b) frame.setLocation(100, 200)
c)frame.setLocation(200, 100) d) frame.setLocation(200, 200)

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


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

110. Which of these methods is used to get x coordinate of the mouse?


a) getX() b) getXCoordinate() c) getCoordinateX() d) getPointX()

111. Which components are used in the following output?

a) Label, TextField, Button b) Applet, Label c) Applet, Button d) Grid Layout, Label, Button

112. What components will be needed to get following output?


a) Label, TabbedPane, CheckBox b) TabbedPane, List, Applet c) Panel, TabbedPane, List
d) Applet, TabbedPane, Panel

113. How to add image in Swing?


a) Using Icon class. b) Using Image class. c) Using ImageIcon class d) Using add( ) method.

114. What is anonymous inner class?


a) An anonymous inner class is one that is not assigned a name.
b) An anonymous inner class is one that is not used for creating the objects
c) An anonymous inner class is one for which we can not create the object.
d) An anonymous inner class is one that which is declared but not used anywhere in the program.

115. How do display (make visible) a String on JProgressBar?


a) Using setString() b) Using setValue() c) Using setStringPainted(true)
d) Using setStringPainted(false)

116. setPreferredSize() method is defined by which class?


a) JProgressBar() b) JFrame() c) JSeparator() d) JPanel

117. Which is the container that doesn't contain title bar and MenuBars but it can have other components
like button, textfield etc?
a) Panel b) Frame c) Window d) Applet

118. Which object can be constructed to show any number of choices in the visible window?
a) Lable b) Button c) Checkbox d) RadioButton

119. Which of these methods are used to know which key is pressed?
a) getActionEvent() b) getKey() c) getActionKey() d) getModifier()
120. What is a listener in context to event handling?
a) A listener is a variable that is notified when an event occurs.
b) A listener is an object that is notified when an event occurs.
c) A listener is a method that is notified when an event occurs. d) None of the mentioned
121. The Following steps are required to perform
1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener
a) Exception Handling b) String Handling c) Event Handling d) None of the above
122. What does the following line of code do?
TextField t1=new TextField(10);
a) Creates a Text object that can hold 10 rows of text. b) Creates the object text & initializes it with
value 10. c) Creates text object that can hold 10 columns of text. d)The code is illegal.

123. class A1
{ public static void main(String ar[])
{ Frame f1=new Frame(); } }
a) Frame window is created b) Frame window created but not seen c) Compilation Error
d) Runtime Error

124. public class my extends Applet


{ public void paint(Graphics g)
{ g.drawString(“Hello”); } }
a) Hello b) Compilation Error c) Run time Error d) None

125. How to set ctrl +M as a shortcut?


a) new MenuShortcut(KeyEvent.VK_M, true) b) new MenuShortcut(KeyEvent.VK_M, false)
c) new MenuShortcut(KeyEvent.VKM, true) d) new MenuShortcut(KeyEvent.VKM, false)

126. class L extends JApplet


{ public void init()
{ ImageIcon i1 = new ImageIcon(“B1.bmp”);
JButton b1=new JButton(i1); add(b1); } }
a) Button is created with specified image b) Button is created without specified image c) Blank output
d) Error

127. public class my extends Applet


{ public void init()
{ Label l1 = new Label(“Hi”); } }
a) Hi b) Compilation Error c) Run time Error d) No output

128. predict the output


class L extends JApplet
{ public void init()
{ JRadioButton r1=new JRadioButton(“1”);
JRadioButton r1=new JRadioButton(“2”);
add(r1); add(r2);} }
a) Both the radio buttons will be selected at a time b) Only 1 radiobutton is selected at a time
c) No output d) Error

129. Which items we can’t directly add to JTree using its constructor?
a) Objects array b) Vector c)Hash table d)Arrays

130. predict the output


public class L extends Applet
{ public void init()
{ TextField t1=new TextField("Welcome to Java");
TextField t2=new TextField(20);
add(t1); add(t2);
t1.select(0,9);
String s=t1.getSelectedText();
t2.setText(s); } }
a) welcome to b) welcometo c) welcome t d) welcomet

Mrs. A. R. Sonawane/ Mr. S. K. Mahajan


Subject Teacher

You might also like