AJP MCQ File3
AJP MCQ File3
(CO-1) 1M
a) Use the setLayout() method b) Once created you cannot change the current layout manager
c) Use the setLayoutManager() method d) Use the updateLayout() method
Q2. The method gets the contents of the text field jtf. (CO-1) 1M
a) jtf.getText(s) b) jtf.getString()
c) jtf.getText( ) d) jtf.findString()
Q3. which of these are valid adapter classes (CO-1) 1M
a) ActionAdapter( ) b) AdjustmentAdapter()
c) TextAdapter d) KeyAdapter
Q4.Which Color is the darkest. (CO-1) 1M
a)new Color(0,0,0) b)new Color(10,0,0)
c)new Color(20,0,0) d)new Color(30,0,0)
Q5. Which class can be used to represent a checkbox with a textual label that can appear in a menu? Select
the one correct answer. (CO-1) 1M
a) MenuBar b)MenuItem
c) CheckboxMenuItem d)Menu
Q6. creates a dropdown list of textual entries (CO-1) 1M
a) Choice b) Checkbox
c) Textbox d) TextComponent
Q7. Event is generated when button is pressed, a list item is double clicked, or a menu item is
selected. (CO-3) 1M
a)ItemEvent b)AdjustmentEvent
c)ActionEvent d)MouseEvent
Q8. Suppose a JFrame uses the GridLayout(0,2). If you add six buttons to the frame, how many
columns are displayed? (CO-2) 1M
a) 1 b) 2
c) 3 d) 4
Q9. What is an event in the delegation event model used by the Java programming language? (CO-3) 1M
a) An event is an object that describes a state change in a source.
b) An event is an object that describes a state change in processing.
c) An event is an object that describes any change by the user and system.
d) An event is a class used for defining object, to create events.
Q10.Which checkbox will be selected in the following code ( Assume with main and added to a Frame)
(CO-1) 2M
Frame myFrame = new Frame("Test");
CheckboxGroup cbg = new CheckboxGroup();
Checkbox cb1 = new Checkbox("First",true,cbg);
Checkbox cb2 = new Checkbox("Second",true,cbg);
Checkbox cb3 = new Checkbox("Third",false,cbg);
cbg.setSelectedCheckbox(cb3);
myFrame.add(cb1);
myFrame.add(cb2);
myFrame.add(cb3);
a)cb1 b)cb2,cb1
c)cb1,cb2,cb3 d)cb3
Q11. select the missing statement in the program for the following output (CO-3) 2M
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=ColorChange width=250 height=300> </applet>*/
public class ColorChange extends Applet implements ActionListener {
Button red;
public void init() {
red=new Button("RED");
add(red); }
public void actionPerformed(ActionEvent e)
{ setBackground(Color.red);
repaint(); }
}
a) addActionListener(this); b) addActionListener();
c) red.addActionListener(); d) red.addActionListener(this)
Q12. Select the missing statement in the program to get the following output (CO-3) 2M
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="ChoiceDemo" width=300 height=180> </applet> */
public class ChoiceDemo extends Applet implements ItemListener {
Choice city;
public void init() {
city.add("Nagpur");
city.add("Mumbai");
city.add("Pune");
city.add("Nashik");
add(city);
city.addItemListener(this); }
public void itemStateChanged(ItemEvent ie)
{ repaint(); }
public void paint(Graphics g) {
String msg = "Select city: ";
msg += city.getSelectedItem();
g.drawString(msg, 6, 120); }
}
a) new Choice(); b) city = new Choice();
c) city = Choice(); d) c= new choice( )
Q15. Consider the following program. Identify which are the event needs to get the correct output. (CO-3) 2M
import java.awt.*;
import java.awt.event.*;
class AEvent extends Frame implements {
TextField tf;
AEvent(){
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);
b. (this);
add(b);add(tf);
setSize(300,300);
setLayout(null);
setVisible(true); }
public void ( e) {
tf.setText("Welcome"); }
public static void main(String args[]) {
new AEvent(); } }