Final Java2
Final Java2
Q1) which of the following statements is for terminating the program when
closing the frame?
A) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
B) frame.setDefaultCloseOperation(null);
c) frame.setDefaultCloseOperation(JFrame.Stop_ON_CLOSE);
D) frame.setDefaultCloseOperation(JFrame.TERMINATE_ON_CLOSE);
Q2) 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) All of the above
Q3) The method ________ sets the background color to yellow in JFrame f
A) f.setBackGroundColor(Color. YELLOW);
B) f.setBackGround(Color. YELLOW);
C) f.setBackColor(Color. YELLOW);
D) f.setBack(Color.YELLOW);
Q4) Given a JLabel label and a JPanel panel with border layout,which of the
following statements would you use to place the label at the top of the
panel?
A) The statement label.add(Panel.NORTH);
B) The statement Panel.add(label.BorderLayout.TOP);
C) The statement label.add(label.NORTH);
D) The statement label.add(label.TOP);
E) The statement Panel.add(label.BorderLayout.NORTH);
Q5) the GridLayout manager arranges components?
A) In the manner the user specifies
B) Left to right,row by row
C) Top to bottom,column by column
D) Depending on the layout manager used inside
Q13) which of the following statement registers the listener refernce for a
button jbt?
A) addActionListener(p);
B) jbt. addActionListener(p);
C) jbt. addActionEventListener(p);
D) jbt.addEventListener(p);
Q14) an inner class is a class defined within the scope of another class
A) true
B) false
Q15) which of the method can be used to determine the source of event?
A) getEventObject();
B) getEvent();
C) getSource();
D) getID();
Q16) the ImageIcon object can be used with?
A) JButton
B) JTextField
C) JPanel
D) All of the above
Q17) which of the following statement correctly adds an action listener to
button btn1?
Public class Quiz extends JFrame implement ActionListener{
JButton btn1;
Quiz(){
btn1=new JButton(text :”ok”);
Add(btn1);
}
Public void actionPerformed(ActionEvent e){
System.out.Println(“hi”);
A) btn1.addActionListener(this);
B) btn1.addActionListener(new ActionListener());
C) btn1.getActionPerformed();
D) btn1.addListener(this);
Q20) In the GridLayout ,if the number of rows and columns are not
determined ,the default number of rows and columns will be?
A) 0,0
B) 1,0
C) 1,1
D) Compilation Error
Q21) if the region is not specified in the BorderLayout, the components will
by default be placed in the :*?
A) South
B) East
C) West
D) North
E) Center